blob: 24d4b69f62a8f498e391fe9c73efe3a3f0747ff3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
public class sumofdigits
{
public static void main(String[] args)
{
System.out.print(sum(23657));
}
public static int sum(int num)
{
if(num == 0)
{
return 0;
}
return (num % 10) + sum(num/10);
}
}
|