Check if a number is divisible by 47 or not | Function to check if the number is divisible by 47 or not ; While there are at least two digits ; Extracting the last ; Truncating the number ; Subtracting fourteen times the last digit to the remaining number ; Finally return if the two - digit number is divisible by 47 or not ; Driver Code
function isDivisible ( n ) { let d ; while ( Math . floor ( n / 100 ) > 0 ) { d = n % 10 ; n = Math . floor ( n / 10 ) ; n = Math . abs ( n - ( d * 14 ) ) ; } return ( n % 47 == 0 ) ; } let N = 59173 ; if ( isDivisible ( N ) != 0 ) document . write ( " " ) ; else document . write ( " " ) ;