Applying above formula [ Note value n & 1 is 1 if n is odd , else 0 ] .
if ( ( n & 1 ) == 1 ) f [ n ] = ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) ; else f [ n ] = ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; }