Check if a larger number divisible by 36 | Function to check whether a number is divisible by 36 or not ; null number cannot be divisible by 36 ; single digit number other than 0 is not divisible by 36 ; number formed by the last 2 digits ; if number is not divisible by 4 ; number is divisible by 4 calculate sum of digits ; sum of digits is not divisible by 9 ; number is divisible by 4 and 9 hence , number is divisible by 36 ; Driver Code
< ? php function divisibleBy36 ( $ num ) { $ l = strlen ( $ num ) ; if ( $ l == 0 ) return " No " ; if ( $ l == 1 && $ num [ 0 ] != '0' ) return " No " ; $ two_digit_num = ( $ num [ $ l - 2 ] - '0' ) * 10 + ( $ num [ $ l - 1 ] - '0' ) ; if ( $ two_digit_num % 4 != 0 ) return " No " ; $ sum = 0 ; for ( $ i = 0 ; $ i < $ l ; $ i ++ ) $ sum += ( $ num [ $ i ] - '0' ) ; if ( $ sum % 9 != 0 ) return " No " ; return " Yes " ; } $ num = "92567812197966231384" ; echo ( divisibleBy36 ( $ num ) ) ; ? >