RosettaCodeData/Task/Calculating-the-value-of-e/ZX-Spectrum-Basic/calculating-the-value-of-e.basic
2023-07-01 13:44:08 -04:00

9 lines
401 B
Text

10 LET p=13: REM precision, or the number of terms in the Taylor expansion, from 0 to 33...
20 LET k=1: REM ...the Spectrum's maximum expressible precision is reached at p=13, while...
30 LET e=0: REM ...the factorial can't go any higher than 33
40 FOR x=1 TO p
50 LET e=e+1/k
60 LET k=k*x
70 NEXT x
80 PRINT e
90 PRINT e-EXP 1: REM the Spectrum ROM uses Chebyshev polynomials to evaluate EXP x = e^x