Happy Pi-Day!

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
Mike
Herr VC
Posts: 4831
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Happy Pi-Day!

Post by Mike »

Happy Pi-Day! :mrgreen:

Here's my take on the Spigot-Algorithm (download):

Code: Select all

1 N=60:M=INT(10*(N+1)/3):DIMD(M-1):FORT=0TOM-1:D(T)=2:NEXT:P=0:FORT=0TON:C=0
2 FORA=M-1TO1STEP-1:B=2*A+1:D=D(A)*10+C:E=INT(D/B):D(A)=D-E*B:C=A*E:NEXT
3 D=D(0)*10+C:E=INT(D/10):D(0)=D-E*10:GOSUB5:NEXT:E=0:GOSUB5:PRINT:END
4 :
5 IFT=2THENPRINT".";
6 ON2+SGN(E-9)GOTO7,8,9
7 PRINTMID$(STR$(P),3);:P=10+E:RETURN
8 P=10*P+9:RETURN
9 P=P+1:GOSUB7:P=10:RETURN
The number of digits can be changed in line 1 ('N=...') within the limits of available memory. The result for N=60:

Image

Cheers,

Michael
User avatar
joshuadenmark
Big Mover
Posts: 1218
Joined: Sat Oct 23, 2010 11:32 am
Location: Fr-Havn, Denmark
Occupation: Service engineer

Re: Happy Pi-Day!

Post by joshuadenmark »

Thanks, same to You :D
image.jpg
image.jpg (20.36 KiB) Viewed 666 times
Kind regards, Peter.
____________________________________________________
In need of a wiki logon - PM me
User avatar
orion70
VICtalian
Posts: 4340
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: Happy Pi-Day!

Post by orion70 »

Living happily in 2015 with a VIC on our desk is really squaring the circle :D
Post Reply