Hello, everyone. I am trying to use a c program I found on the Internet:

Code:

int main(void){
int a[3302],b=3301,*c=a,d,e,f;
for(e=b; --e; *c++=1)
;
*c=2;
for(d=2001; d--; printf("%05d",f)) {
for(c=a, e=b; e; f/=e--){
f += *c * 1e5;
*c++ = f%e;
}
}
}

(I did insert an extra line at the end after the compiler complained about the lack of it.)

I am trying to figure out why it does not seem to be giving me the right value for e. It did compile with some warnings but no fatal errors. The main warning were for the printf and for line 8 converting integer to floating point.

Personally, I can say that I used to write c programs and fortran 77 programs when I studied at uCsD 1995-97 as well at mathlab at Pomona college 1994-5. But I'm a little rusty and I'm not that clear on what all the syntax is supposed to be doing: a[3302], *c, the single ; for line 4, printf("%05d",f) does what?, and lastly, *c++ = f%e; has % and I don't know what that does, again.

I do have a basic grasp of the three for loops and what the basic math operations are doing, but without really understanding the program, I don't know how to adapt it to what I want to do, namely, to calculate even more digits of e (correctly, of course).

It took me a few hours of looking around on the Internet to finally find a spigot algorithm that I could put into a computer language to try to calculate the base of natural logarithms. There were many formulas that produce e and various similar values (e^x, 1/e, etc), and I read that e has only been calculated out to a billion decimal places, so if the spigot algorithm could allow me to pick up where I leave off, then I can keep adding to my collection of digits.

Help is greatly appreciated.