OK so Google wants you to find a prime in e, so lots of people are into e at the moment. Given I can get a couple of million digits of e online (and I've already answered both quiz questions just to see where it led) I am interested in why/how the algorithms at e actually work.
Euler's original equation e = 1 + 1/1! + 1/2! + 1/3! .... is obviously limited in accuracy by the size of the floating point value you can work with. To calculate a lot of digits, an alternative approach is needed which is not limited by the accuracy of the floating point you can work with. Now you can express e as e=1+1+1/2(1+1/3(1+1/4(1+1/5(1+.....)))) which means that when you work from the inside out the calculations only use small integer division. I presume that this is what is being done at e with the reverse walking and a carry up the integer array. The thing is I simply don't get it? Anyone able to enlighten me or provide a reference? This looks simple enough.....
sub e{ @e=(1)x pop; for(1..@e){ for(reverse(1..$#e)){ $e[$_-1]+=$e[$_]/$_; $e[$_]=10*($e[$_]%$_) } print int $e[0]; $e[0]=0 } }
Mazal tov.
In reply to Caclulation of e by doc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |