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