Number is divisible by 29 or not | Returns true if n is divisible by 29 else returns false . ; add the lastdigit * 3 to remaining number until number becomes of only 2 digit ; return true if number is divisible by 29 another ; Driver Code
< ? php function isDivisible ( $ n ) { while ( intval ( $ n / 100 ) ) { $ last_digit = $ n % 10 ; $ n = intval ( $ n / 10 ) ; $ n += $ last_digit * 3 ; } return ( $ n % 29 == 0 ) ; } $ n = 348 ; if ( isDivisible ( $ n ) ) echo " Yes " ; else echo " No " ; ? >