Write a Java program to sum up all the digits of an integer till the sum is a single digit. code example
Example: Java program to find the sum of all the digits in the inputted number
long number, sum;
Scanner sc = new Scanner(System.in);
System.out.println("Enter any DIGIT number: ");
number = sc.nextLong();
sc.close();
// For Logic for adding all digits in the given number
for (sum = 0; number != 0; number /= 10) {
sum += number % 10;
}
System.out.println("ForLoop Sum of ALL digits: " + sum);