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 ; Driver Code ; divisible ; if divisibleBy75
< ? php function divisibleBy3 ( $ number ) { $ sumOfDigit = 0 ; for ( $ i = 0 ; $ i < strlen ( $ number ) ; $ i ++ ) $ sumOfDigit += $ number [ $ i ] - '0' ; if ( $ sumOfDigit % 3 == 0 ) return true ; return false ; } function divisibleBy25 ( $ number ) { if ( strlen ( $ number ) < 2 ) return false ; $ length = strlen ( $ number ) ; $ lastTwo = ( $ number [ $ length - 2 ] - '0' ) * 10 + ( $ number [ $ length - 1 ] - '0' ) ; if ( $ lastTwo % 25 == 0 ) return true ; return false ; } function divisibleBy75 ( $ number ) { if ( divisibleBy3 ( $ number ) && divisibleBy25 ( $ number ) ) return true ; return false ; } $ number = "754586672150" ; $ divisible = divisibleBy75 ( $ number ) ; if ( $ divisible ) echo " Yes " ; else echo " No " ; ? >