Project Euler 101 - Optimum Polynomial

Official link: https://projecteuler.net/problem=101

Thought Process

After some research I found Lagrange Polynomial, see Polynomial Interpolation for other ideas.

Lagrange polynomial is the method we will use to create our OP(k,n) the next term will be our FIT so we just need to calculate one term in advance.

The first 10 numbers of the sequence are (1,1),(2,683),(3,44287),(4,838861),(5,8138021),(6,51828151),(7,247165843),(8,954437177),(9,3138105961),(10,9090909091), so we just need to take ther first k points for OP(k,n)

After that I just implemented the wikipedia formula! My code is included below

Interactive Code

No interactive code for this problem, my code is given below.