Post Reply 
e-Day
07-04-2018, 07:06 PM
Post: #8
RE: e-Day
(07-03-2018 11:25 PM)Valentin Albillo Wrote:  The C program posted by Mr. Klemm was obviously taken from the book "Obfuscated C and other mysteries", page 260.

Nah, I found it in Pi Unleashed by Arndt, Jörg, Haenel, Christoph on page 36.

Quote:It's a very interesting book, I can heartily recommend it.

Pi Unleashed is another book that we full-heartedly recommend.

Later on page 85 they show this small program that calculates e to 15,000 places:
Code:
/* note: N=15000, LEN=87700 >= 1.4*N*log10(N), 84700=LEN-N/5 */
a[87700],b,c=87700,d,e=1e4,f=1e5,h;
main(){for(;b=c--,b>84700;h=printf("%05d",e+d/f),e=d%=f)
for(;--b;d+=f*(h?a[b]:e),a[b]=d%b,d/=b);}
Both programs use the spigot algorithm to calculate e.

Cheers
Thomas

PS: Here's a link to Roemer B. Lievaart wining contribution of 1989 for the best layout.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
e-Day - Pjwum - 07-02-2018, 12:41 PM
RE: e-Day - Thomas Klemm - 07-02-2018, 01:57 PM
RE: e-Day - Valentin Albillo - 07-02-2018, 06:24 PM
RE: e-Day - Pjwum - 07-03-2018, 11:53 AM
RE: e-Day - Dieter - 07-03-2018, 09:37 PM
RE: e-Day - Valentin Albillo - 07-03-2018, 11:25 PM
RE: e-Day - Pjwum - 07-04-2018, 06:46 PM
RE: e-Day - Thomas Klemm - 07-04-2018 07:06 PM
RE: e-Day - Thomas Klemm - 07-06-2018, 09:27 PM



User(s) browsing this thread: 1 Guest(s)