Q&A Discussions
I'm trying to calculate the decimal places of pi with Ramanujan's formula. but with this code I'm getting the same output for all values of n, which it shouldn't.
from math import sqrt, factorial as f
sum=0
n=0
k=(2*sqrt(2)/9801)
while n<=100000:
sum=sum+((f(4*n))*(1103+(26390*n)))/(((f(n))**4)*(396**(4*n)))
y=1/(k*sum)
print('%.60f' % y)
n=n+1
where am I doing wrong?
2 Votes
4 AnswersPHP execution timed out
0 Votes
2 AnswersWhat's Wrong With My Code??
0 Votes
2 AnswersSimple code issue
1 Vote
1 AnswerHaha I'm getting better
0 Votes
2 Answersvariable is ambiguous
0 Votes
2 AnswersHow to use "WHILE"
0 Votes
1 Answerpyton array Q!
0 Votes
1 AnswerSubtraction problem
0 Votes
3 AnswersMoney Rate Income
1 Vote
1 AnswerIn the continue Loop -
i = 0
while True:
i = i +1
if i == 2:
print("Skipping 2")
continue
if i == 5:
print("Breaking")
break
print(i)
print("Finished")
It shows the output being
"1
Skipping 2
3
4
Breaking
Finished"
Why are the last three lines not
"Breaking
5
Finished"
Where it shows print(i) after break?
1 Vote
3 AnswersHot today
Where is all of the lecon?
1 Votes
Is there any free coding app?
1 Votes
Not getting Badge issue
1 Votes
Slicing in py
0 Votes
Notes app bug
1 Votes
Cube Roots
1 Votes
BASIC
0 Votes
Association rule mining
1 Votes