Check if a large number is divisibility by 15 | to find sum ; function to check if a large number is divisible by 15 ; length of string ; check divisibility by 5 ; Sum of digits ; if divisible by 3 ; Driver Code
< ? php function accumulate ( $ s ) { $ acc = 0 ; for ( $ i = 0 ; $ i < strlen ( $ s ) ; $ i ++ ) { $ acc += $ s [ $ i ] - '0' ; } return $ acc ; } function isDivisible ( $ s ) { $ n = strlen ( $ s ) ; if ( $ s [ $ n - 1 ] != '5' && $ s [ $ n - 1 ] != '0' ) return false ; $ sum = accumulate ( $ s ) ; return ( $ sum % 3 == 0 ) ; } $ s = "15645746327462384723984023940239" ; isDivisible ( $ s ) ? print ( " Yes STRNEWLINE " ) : print ( " No STRNEWLINE " ) ; $ s = "15645746327462384723984023940235" ; isDivisible ( $ s ) ? print ( " Yes STRNEWLINE " ) : print ( " No STRNEWLINE " ) ; ? >