Check if a large number is divisible by 75 or not | check divisibleBy3 ; to store sum of Digit ; traversing through each digit ; summing up Digit ; check if sumOfDigit is divisibleBy3 ; check divisibleBy25 ; if a single digit number ; length of the number ; taking the last two digit ; checking if the lastTwo digit is divisibleBy25 ; Function to check divisibleBy75 or not ; check if divisibleBy3 and divisibleBy25 ; Drivers code ; divisible ; if divisibleBy75
function divisibleBy3 ( number ) { let sumOfDigit = 0 ; for ( let i = 0 ; i < number . length ; i ++ ) sumOfDigit += number [ i ] - ' ' ; if ( sumOfDigit % 3 == 0 ) return true ; return false ; } function divisibleBy25 ( number ) { if ( number . length < 2 ) return false ; let length = number . length ; let lastTwo = ( number [ length - 2 ] - ' ' ) * 10 + ( number [ length - 1 ] - ' ' ) ; if ( lastTwo % 25 == 0 ) return true ; return false ; } function divisibleBy75 ( number ) { if ( divisibleBy3 ( number ) && divisibleBy25 ( number ) ) return true ; return false ; } let number = " " ; let divisible = divisibleBy75 ( number ) ; if ( divisible ) document . write ( " " ) ; else document . write ( " " ) ;