Check if a large number is divisible by 9 or not | Java program to find if a number is divisible by 9 or not ; Function to find that number is divisible by 9 or not ; Compute sum of digits ; Check if sum of digits is divisible by 9. ; main function
class IsDivisible { static boolean check ( String str ) { int n = str . length ( ) ; int digitSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) digitSum += ( str . charAt ( i ) - '0' ) ; return ( digitSum % 9 == 0 ) ; } public static void main ( String [ ] args ) { String str = "99333" ; if ( check ( str ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }