[VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
|
04-02-2019, 10:43 PM
Post: #24
|
|||
|
|||
RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
Hi, all: Continuing with my original solutions, today it's time for: Tier 4 - The Challenge: Consider the n-point dataset (1, 2), (2, 3), (3, 5), (4, 7), (5, 11), (6, 13), ..., (n, pn) (the prime numbers), and the (n-1)st degree polinomial fit to this dataset of the form: P(x) = a0 + a1 (x-1) + a2 (x-1) (x-2) + ... + an-1 (x-1) (x-2) (x-3) ... (x-(n-1)) Write a program that takes no inputs but computes and outputs the limit of the sum of the coefficients a0, a1, ... , an-1 when n tends to infinity. My original solution: My original solution for the HP-71B is this 4-liner (168 bytes): 1 DESTROY ALL @ OPTION BASE 0 @ REPEAT @ N=N+1 @ DIM C(N) @ T=S 2 FOR I=1 TO N @ C(I)=FPRIM(C(I-1)+1) @ NEXT I @ S=0 3 FOR I=1 TO N-1 @ FOR J=N TO I+1 STEP -1 @ C(J)=C(J)-C(J-1) @ NEXT J @ NEXT I 4 FOR I=1 TO N @ S=S+C(I)/FACT(I-1) @ NEXT I @ UNTIL S=T @ DISP N;S >RUN 20 3.40706916561 { it converged to the limit after fitting the first 20 primes: 2, 3, 5, ..., 71) } Notes:
That's all for Tier 4, thanks a lot to Albert Chan for his interest in this particular tier and congratulations for providing a correct solution and some explanation but please, Albert, next time *do* provide actual code for an HP calculator of your choice, so that people can try your solution for themselves. In the next days I'll post my solutions for the remaining tiers. V. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 8 Guest(s)