Initializing u and sum
double sum = y [ n - 1 ] [ 0 ] ; double u = ( value - x [ n - 1 ] ) / ( x [ 1 ] - x [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { sum = sum + ( u_cal ( u , i ) * y [ n - 1 ] [ i ] ) / fact ( i ) ; } System . out . println ( " Value at " + value + " ▁ is ▁ " + String . format ( " % .6g % n " , sum ) ) ; } }