Fix happy number algorithm.

Don't code when drunk or test it.
This commit is contained in:
Nicolas Cornu 2017-09-29 15:26:47 +02:00 committed by GitHub
parent 27c6db1448
commit 3c1f2c1d8e

View File

@ -7,14 +7,14 @@ int main()
int n,k,s=0,d;
cout << "Enter a number:";
cin >> n;
s=n;k=n;
s=0;k=n;
while(k>9)
{
while(k!=0)
{
d=n%10;
d=k%10;
s+=d;
n/=10;
k/=10;
}
k=s;
s=0;