Search found 2 matches
- Fri Nov 28, 2003 6:59 pm
- Forum: Coding Questions
- Topic: Pi
- Replies: 4
- Views: 2990
Thank you. I know there are much better ways to calculate Pi. But i intended to program all known algorithms, starting with the easiest, to learn programming (and maths). I think one solution would be to round the variables at a certain point, or somehow try to calculate with integers (wich, on the ...
- Thu Nov 27, 2003 9:34 pm
- Forum: Coding Questions
- Topic: Pi
- Replies: 4
- Views: 2990
Pi
;Pi = 4 - 4/3 + 4/5 - 4/7 + 4/9...
DefType.f p
DefType.f n
n = 1
p = 4
OpenConsole()
loop:
p = p -(4/(n+2)) + (4/(n+4)) ;the algorithm
n = n + 4
c = c + 1 ; update the result every 1000000th cycle
If c = 1000000
Gosub output
EndIf
Goto loop
output:
ConsoleLocate(1, 1)
PrintN(StrF ...
DefType.f p
DefType.f n
n = 1
p = 4
OpenConsole()
loop:
p = p -(4/(n+2)) + (4/(n+4)) ;the algorithm
n = n + 4
c = c + 1 ; update the result every 1000000th cycle
If c = 1000000
Gosub output
EndIf
Goto loop
output:
ConsoleLocate(1, 1)
PrintN(StrF ...