'While installing Homebrew, connection failed error comes up when run this command " sudo apt-get install build-essential". What to do about it?

enter image description here

I am just starting with web3 development. I have installed WSL. Then I opened Ubuntu and installed Homebrew. When the installation is almost complete it asks for next steps which is providing the path and installing the dependencies. After providing the path when I ran this command " sudo apt-get install build-essential" it gave me connection failed error as shown in the pic.

Then I turned Windows Defender off and tried again but didn't work.

Then I tried to paste the same url in my browser but it didn't work. My guess is that url is different or wrong, but I don't know.

I also tried running this command "sudo apt-get update" but it also gives the same error.

Same error with this as well "sudo apt-get install build-essential procps curl file git"

Any idea what to do about this?

Note:- Just wanted to let you know that When I check "brew -version" it shows me my version 3.4.11. And my Ubuntu version is 20.04.



Solution 1:[1]

I thought this was an interesting question, despite most likely being a homework problem, and one of my goals right now is learning recursion. Thus, I feel like this is a good opportunity to practice.

So the thing about Liu Hui series is that there's one part that's recursive and (the nested square roots) and the other part belongs to the formula, I think of this as being outside the recursion.

Thus, my code is:

def liuHuiPi(iterations):
    if iterations ==1:
        return 1
    else:
        iterations-=1
        return math.sqrt(2+liuHuiPi(iterations))

iterations = 20
estimate = 3*math.pow(2,iterations-1)*math.sqrt(2-liuHuiPi(iterations))

print(estimate)

Note: I believe there are some limitations in the calculations as you go higher with the number of iterations that will lead to less accurate results. In particular, n=15 is the highest we can get without arbitrary precision decimals, according to this analysis.

Output:

3.1415868396550413

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1