This question already has an answer here:
- Rational Polynomial Interpolation 2 answers
A sequence of numbers is passed in as the input. The program has to generate the lowest degree polynomial possible. This was my first programming project in college and it would be interesting to see how much smaller the solution could have been.
The input is a list of integers separated by a comma. The output is simply the equation that generates that sequence. The exact output of the equation is up to you i.e. no spaces are required between terms of the polynomial but it has to be human readable. The equation has to be expressed with the variable x. The first integer in the supplied sequence will correspond with x = 1, the second integer supplied would be x = 2 etc.
would result in the sequence
1,4,9,16 NOT 0,1,4,9
Example Input and Output
2x^2 + 3x
I marked the questions as duplicate, thanks for the head up.