Value of the series ( 1 ^ 3 + 2 ^ 3 + 3 ^ 3 + ... + n ^ 3 ) mod 4 for a given n | function for obtaining the value of f ( n ) mod 4 ; Find the remainder of n when divided by 4 ; If n is of the form 4 k or 4 k + 3 ; If n is of the form 4 k + 1 or 4 k + 2 ; Driver code
< ? php function fnMod ( $ n ) { $ rem = $ n % 4 ; if ( $ rem == 0 or $ rem == 3 ) return 0 ; else if ( $ rem == 1 or $ rem == 2 ) return 1 ; } $ n = 6 ; echo fnMod ( $ n ) ; ? >