double newton(double *x, double *y, int n, double num, int cur, int pointNum, double answer)
{
// Calculate mean difference
for(int i = pointNum -1; igt; cur; i--)
{
y[i] = ( y[ i] - y[i-1] ) / ( x[i] - x[i-1] );
}
//cur has been calculated and added
p>cur ;
//temp is temporarily calculated
double temp = y[cur];
for(int i= 0; ilt ; cur; i )
{
temp *= ( num - x[i] );
}
//Will The temporary calculation result is added to answer
answer = temp;
//If the desired result is obtained, return the answer otherwise continue the calculation
if(cur= =n)
return answer;
else
return newton(x, y, n, num, cur, pointNum, answer); /// less return
}