• + 0 comments

    java solution

    public static int super_Digit(String str, int k) { int num = Integer.parseInt(str);

        if (str.length() == 1) {
            return num;
        }
        int sum = 0;
    
        int rev = 0;
        while (num != 0) {
            rev = num % 10;
            sum = sum + rev;
            num = num / 10;
    
        }
    
        String newstring = String.valueOf(sum);
    
        return super_Digit(newstring, newstring.length());
    
    }