1=1
12=1+2=3
36=3+6=9
123456789=1+2+3+4+5+6+7+8+9=45
12=1+2=3
36=3+6=9
123456789=1+2+3+4+5+6+7+8+9=45
import java.io.*;
class Example
{
public static void main(String args[])
{
int a,n,sum=0;
Console con = System.console();
n = Integer.parseInt(con.readLine());
while(n!=0)
{
a=n%10;
sum = sum+a;
n=n/10;
}
System.out.print(n+" series add is"+sum);
}
}
Comments
Post a Comment