I m trying to check if the no is happy or not : if sums of square of its digits = 1 then happy
#include
using namespace std;
int main() {
int num = 32;
int happy_number=0;
int result =0;
int last_digits =0;
while(num != 1) {
while(num >= 1) {
last_digits = num%10; // take the last digits
result += last_digits * last_digits;
num = num/10;
}
if(result == 1) {
happy_number=1;
break;
}
num = result;
}
cout << happy_number;
return 0;
}