[VA] SRC #012c - Then and Now: Sum
|
12-04-2022, 09:54 AM
(This post was last modified: 12-04-2022 10:42 AM by Albert Chan.)
Post: #33
|
|||
|
|||
RE: [VA] SRC #012c - Then and Now: Sum
(12-04-2022 08:49 AM)Werner Wrote: - Why does Albert’s code run so much slower than J-F’s, while doing 31 loops vs 40? > 20 DIM F(63) @ F(2)=2 @ F(3)=6 @ B=4 > 30 FOR X=3 TO 6 @ FOR Y=B TO B+B-1 @ F(Y)=Y*F(X) @ NEXT Y @ B=B+B @ NEXT X > 80 FNZ=Z/F(N) @ END DEF >RUN 2.086377665 31 0.05 Above patch removed FNB(N) and FNF(N), and build list of F(N) instead. F(N=63) is enough, since (G-LN2) shrink at O(1/2^n) For 12 decimal digits, we need at most N=12/LOG10(2) ≈ 40 Z = (G-LN2)/F, with F growing faster than primes, O(n*ln(n)), it needed even less than that. Cached F doubled program speed (translated to HP71B runtime of about 10s) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)