Check if a large number is divisible by 2 , 3 and 5 or not | function to return sum of digits of a number ; function to Check if a large number is divisible by 2 , 3 and 5 or not ; Driver code
< ? php function SumOfDigits ( $ str , $ n ) { $ sum = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ sum += ( int ) ( $ str [ $ i ] - '0' ) ; return $ sum ; } function Divisible ( $ str , $ n ) { if ( SumOfDigits ( $ str , $ n ) % 3 == 0 and $ str [ $ n - 1 ] == '0' ) return true ; return false ; } $ str = "263730746028908374890" ; $ n = strlen ( $ str ) ; if ( Divisible ( $ str , $ n ) ) echo " YES " ; else echo " NO " ; ? >