Introduction
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.
Challenge
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.
i.e.
x^2
would result in the sequence
1,4,9,16 NOT 0,1,4,9
Example Input and Output
Input:
5,14,27,44
Output:
2x^2 + 3x
Edit
I marked the questions as duplicate, thanks for the head up.
2 Answers 2
-
\$\begingroup\$ Not to mention that this does not use infix notation.
:/\$\endgroup\$user202729– user2027292018年04月15日 12:04:25 +00:00Commented Apr 15, 2018 at 12:04 -
\$\begingroup\$ @user202729 does it need to? \$\endgroup\$ASCII-only– ASCII-only2018年04月15日 12:40:57 +00:00Commented Apr 15, 2018 at 12:40
Explore related questions
See similar questions with these tags.
[1..n]adds much to the existing challenges. \$\endgroup\$