pie calcualation project, almost done, just need some help
hey whats up cboard, my teacher gave me a project to do. She wants us to write a program that will calculate this equation: pi *4*(1-1/3+1/5+1/7+1/9-1/11+1/13-1/(2*i)+1/(2*100+i))
she said to calculate for i = 100, 1000, and 100000
I have to use a while loop, and when i do it it works for 100, but for 1000 and 100000 it says inf, is there a way to fix this?
this is what i get in cmd:
PI1 = 5.0482e+060
PI2 = 1.#INF
PI3 = 1.#INF
Press any key to continue . . .
any help is appreciated, i can show my code if requested.
also this is very inaccurate method
very naive method of finding pi :(
see my output . . .
Code:
>>> mpi(10)
pi 3.04183961893
>>> mpi(100)
pi 3.13159290356
>>> mpi(1000)
pi 3.14059265384
>>> mpi(10000)
pi 3.14149265359
>>> mpi(100000)
pi 3.14158265359
>>> mpi(1000000)
pi 3.14159165359
>>> mpi(10000000)
pi 3.14159255359
>>>