Check if the n | PHP Program to check if the nth is odd or even in a sequence where each term is sum of previous two term ; Return if the nth term is even or odd . ; Return true if odd ; Driver Code
< ? php $ MAX = 100 ; function findNature ( $ a , $ b , $ n ) { global $ MAX ; $ seq = array_fill ( 0 , $ MAX , 0 ) ; $ seq [ 0 ] = $ a ; $ seq [ 1 ] = $ b ; for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) $ seq [ $ i ] = $ seq [ $ i - 1 ] + $ seq [ $ i - 2 ] ; return ( $ seq [ $ n ] & 1 ) ; } $ a = 2 ; $ b = 4 ; $ n = 3 ; if ( findNature ( $ a , $ b , $ n ) ) echo " Odd " ; else echo " Even " ; ? >