Polynomial degree is a pure assembly project. The goal is to implement the following function

int polynomial_degree(int const *y, size_t n);

The function takes two arguments: a pointer y to an array of integers $y_0,y_1,\ldots,y_{n-1}$ and an integer n representing the length of this array. The function calculates the lowest degree of a single-variable polynomial $w(x)$ with real coefficients, such that: $w(x+k\cdot r)=y_k$ for some real number $x$, a nonzero real number $r$, and $k=0,1,\ldots,n-1$.

Examples:

  • For input $y=[-3,0,3]$, the result is a polynomial of degree 1.
  • For input $y=[1,4,9,16]$, the result is a polynomial of degree 2.

Source code