import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number: "); long number = input.nextLong(); input.close(); System.out.println("The sum of the number is " + sumDigits(number)); } public static long sumDigits(long n) { if(n < 10) return n; else return n % 10 + sumDigits(n / 10); } }