Problem Statement
The function f is a polynomial of degree at most 5. In other words, there are some integers c0 through c5 (some of them possibly zero) such that for all x we have the following:
f(x) = c0 + c1 * x + c2 * x2 + ... + c5 * x5
You are given the int[] p with the following meaning: for each i between 0 and 5, inclusive, f(i) = p[i].
Compute and return f(6).
Definition
- Class:
- PolynomialGuess
- Method:
- findValue
- Parameters:
- int[]
- Returns:
- int
- Method signature:
- int findValue(int[] p)
- (be sure your method is public)
Constraints
- p will have exactly 6 elements.
- Each element of p will be between -100 and 100, inclusive.
Examples
{10,11,12,13,14,15}Returns: 16
This is the linear function f(x) = x + 10.{2,5,7,12,19,31}Returns: 64