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
function SumOfDigits ( str , n ) { var sum = 0 ; for ( var i = 0 ; i < n ; i ++ ) sum += ( str . charAt ( i ) - ' ' ) ; return sum ; } function Divisible ( str , n ) { if ( SumOfDigits ( str , n ) % 3 == 0 && str . charAt ( n - 1 ) == ' ' ) return true ; return false ; } var str = " " ; var n = str . length ; if ( Divisible ( str , n ) ) document . write ( " " ) ; else document . write ( " " ) ;