I don't know about fast, but... for example, using the definitions at https://code.jsoftware.com/wiki/Essays/Extended_Precision_Functions
0j100 ": 100 exp 1 2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274 If I wanted fast, though, I'd probably do something along the lines of: htm=. gethttp 'https://www.math.utah.edu/~pa/math/e.html' (LF,' ')-.~({.~ '...' I.@E. ]) (}.~ '2.71828' I.@E. ]) htm 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746639193200305992181741359662904357290033429526059563073813232862794349076323382988075319525101901157383418793070215408914993488416750924476146066808226... (Except I'm sure there's better urls for this sort of approach.) Probably not what you were looking for, though... -- Raul On Thu, Jul 25, 2019 at 11:04 AM Ulrich Vollert <[email protected]> wrote: > > Hello, > > I came across ’The Google Test’ by Eugene McDonnell > (https://www.jsoftware.com/papers/play211.htm > <https://www.jsoftware.com/papers/play211.htm>) and was wondering how to > calculate many digits of Euler’s number e. > > I found an (ancient) article "The calculation of e to many significant > digits" by A. H. J. Sale in The Computer Journal 11(2) · August 1968 > (https://www.researchgate.net/publication/266281843_The_Calculation_of_e_to_Many_Significant_Digits > > <https://www.researchgate.net/publication/266281843_The_Calculation_of_e_to_Many_Significant_Digits>) > which uses a clever algorithm implemented in Algol 60 (!) to calculate e > digit by digit and using only integer arithmetic. > > With this algorithm in J (see below) I could calculate as many digits of e > as I want (I used 140 digits) and solved the Google Test which asks for: > > 1. First 10-digit prime found in consecutive digits of e. > > 2. The number F(5) which follows > > F(1)= 7182818284 > F(2)= 8182845904 > F(3)= 8747135266 > F(4)= 7427466391 > F(5)=__________ > > (BTW In the article of Eugene McDonell the second number F(2) contains > transposed digits 9 and 0.) > > Here is my question: > > How would you calculate many significant digits of e in J? > > Regards, > Ulrich > > > NB. *** problem 1 *** > > NB. value to check m > checkm =: 3 : 0 > r =. -: ^. 6.2831852 * y > r + y * (^. y) - 1 > ) > > NB. given the number of digits of e which are wanted, > NB. calculate the number of required terms > number_of_terms =: 3 : 0 > test =. 2.30258509 * >: y > (>: ^: (test&>: @: checkm) ^:_) 4 > ) > > NB. from JforC > LoopWithInitial =: 2 : 'u&.>/\.&.(,&(<v))&.|.&.(<"_1)' > > NB. x is coeff and y is j, carry, follwed by the coeffs so far > NB. answer are the next j and carry, the new coeff, and old coeffs > term =: 4 : 0 > j =. {. y > carry =. 1 { y > coeffs =. 2 }. y > temp =. carry + 10 * x > (<: j), ((0, j) #: temp), coeffs > ) > > NB. initialise with m > init =: 3 : 0 > term LoopWithInitial (y, 0) (<: y) $ 1 > ) > > NB. given is an output of term LoopWithInitial > NB. find next output > next =: 3 : 0 > NB. take last row of output of term LoopWithInitial > NB. the row contains: j carry coeffs > last =. {: y > NB. carry is the next digit of e, forget j > ee =: ee , ": 1 { last > term LoopWithInitial ((<: #last), 0) |. 2 }. last > ) > > NB. calculate the number of digits of e > NB. the digits are collected in a global variable ee > calc_e =: 3 : 0 > ee =: '' > next^:y init number_of_terms y > ee > ) > > digits_e =: ". 10 ]\ calc_e 140 > > solution1 =: {. (I. 1 p: digits_e) { digits_e > NB. -> 7427466391 > > NB. *** problem 2 *** > > NB. cross sum of a number > csum =: 3 : '+/ "."0 ": y' > > NB. the given numbers have all the same cross sum of 49 > NB. csum"0 (7182818284 8182845904 8747135266 7427466391) -> 49 49 49 49 > > NB. find the next number in the digits of e with a cross sum of 49 > solution2 =: 4 }. (] {~ [: I. 49 = csum"0) digits_e > NB. -> 5966290435 > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
