Hi,
How do I calculate pi using LiveCode?
I know that LiveCode has the built in pi constant, but I want more decimal places.
Also, I know I could just copy and paste pi from a website into my program, but the whole fun is having it go on and on and on...
Andrew
Calculating pi
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 184
- Joined: Wed Apr 10, 2013 5:09 pm
Re: Calculating pi
Code: Select all
on mouseUp
set the numberformat to 0.000000000000000
put 22/7 into fld 1
end mouseUp
Re: Calculating pi
..........
Last edited by [-hh] on Wed Aug 13, 2014 12:11 pm, edited 1 time in total.
shiftLock happens
Re: Calculating pi
One of the oddest is:
1/π = 2√2 / 9801 * ∑ (4k)! (1103 + 26390k) / (k!)^4 * 396^4k
The sum taken from 0 to infinity.
Ramanujan did this in his head.
This looks like it could be readily worked out with LC. A repeat loop could run the summation for a while.
Craig
EDIT. I have a feeling the digits get out of hand pretty soon...
1/π = 2√2 / 9801 * ∑ (4k)! (1103 + 26390k) / (k!)^4 * 396^4k
The sum taken from 0 to infinity.
Ramanujan did this in his head.
This looks like it could be readily worked out with LC. A repeat loop could run the summation for a while.
Craig
EDIT. I have a feeling the digits get out of hand pretty soon...