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
function isDivisible ( n ) { while ( parseInt ( n / 100 ) ) { let last_digit = n % 10 ; n = parseInt ( n / 10 ) ; n += last_digit * 3 ; } return ( n % 29 == 0 ) ; } let n = 348 ; if ( isDivisible ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;