Find the remainder when First digit of a number is divided by its Last digit | Function to find the remainder ; Get the last digit ; Get the first digit ; Compute the remainder ; Driver code
function findRemainder ( n ) { let l = n % 10 ; while ( n >= 10 ) n /= 10 ; let f = n ; let remainder = f % l ; document . write ( Math . floor ( remainder ) ) ; } let n = 5223 ; findRemainder ( n ) ;