Gapful Numbers | Find the first digit ; Find total number of digits - 1 ; Find first digit ; Return first digit ; Find the last digit ; Return the last digit ; A function to check Gapful numbers ; Return true if n is gapful number ; Given number ; Function call
function firstDigit ( n ) { let digits = parseInt ( ( Math . log ( n ) / Math . log ( 10 ) ) ) ; n = parseInt ( ( n / Math . pow ( 10 , digits ) ) ) ; return n ; } function lastDigit ( n ) { return ( n % 10 ) ; } function isGapful ( n ) { let first_dig = firstDigit ( n ) ; let last_dig = lastDigit ( n ) ; let concatenation = first_dig * 10 + last_dig ; return ( n % concatenation == 0 ) ; } let n = 108 ; if ( isGapful ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;