- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# To check divisibility of any large number by 9 in java

If the sum of the digits of a number is divisible by 9, then the number is divisible by 9.

Some examples of numbers divisible by 9 are as follows.

- The number 51984 is divisible by 9 because the sum of its digits (5+ 1 + 9 + 8 + 4 = 27) is divisible by 9.
- The number 91403 is not divisible by 9 because the sum of its digits (9 + 1 + 4 + 0 + 3 = 17) is not divisible by 9.

#### Program

import java.util.Scanner; public class DivisibleBy9 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter a number :"); String num = sc.nextLine(); int digitSum = 0; for(int i = 0; i<num.length(); i++){ digitSum = digitSum + num.charAt(i)-'0'; } if(digitSum % 9 == 0){ System.out.println("Given number is divisible by 9"); } else { System.out.println("Given number is not divisible by 9"); } } }

#### Output

Enter a number : 51984 Given number is divisible by 9

- Related Questions & Answers
- Check if a large number is divisibility by 15 in C++
- Divisibility by 12 for a large number in C++ Program
- Check if any permutation of a large number is divisible by 8 in Python
- Check if a large number is divisible by 9 or not in C++
- Check if any large number is divisible by 17 or not in Python
- Check if any large number is divisible by 19 or not in Python
- Check if a large number is divisible by 11 or not in java
- Check if a large number is divisible by 3 or not in java
- Fibonacci of large number in java
- Check if a large number is divisible by 20 in C++
- C Program to check if a number is divisible by any of its digits
- Check if a large number is divisible by 13 or not in C++
- Check if a large number is divisible by 11 or not in C++
- Check if a large number is divisible by 25 or not in C++
- Check if a large number is divisible by 3 or not in C++

Advertisements