Seshadri M

Seshadri M

  • NA
  • 69
  • 17.7k

Sum of square digits from give numbers until single digits

Sep 13 2017 5:16 AM

// I need sum of square digits from give numbers until single digitls
//Example 125
// 1*1+2*2+5*5
// 30
//3*3+0
//9

1+4+25
Public static Void Main()
{
int number;
int result=0;
number =int32.Parse(Console.ReadLine());
if(result !=1)
{
While(number!-0)
{
r =number%10;
sum = sum + r;
number =number /10
}
result =sum;
number=sum;
Console.WriteLine(sum);
}
}
// by using method i am getting as 30


Answers (1)