Super digit program in java
previous NextExample
import java.util.Scanner;
class Raj
{
public static void main(String[] args) {
int n;
int x;
int s;
Scanner sc = new Scanner(System.in);
System.out.print("Enter any number: ");
n = sc.nextInt();
while(n>=10)
{
x = n;
s = 0;
while(x>0)
{
s = s+(x%10);
x = x/10;
}
n = s;
}
System.out.print("Super Digit of the given number is "+n );
}
}
Output :
Enter any number: 56465 Super Digit of the given number is 8