Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class Solution {
  4. public:
  5. bool isHappy(int n) {
  6. while (n > 6) {
  7. int res = 0;
  8. while (n > 0) {
  9. res += (n % 10) * (n % 10);
  10. n /= 10;
  11. }
  12. n = res;
  13. }
  14. return n == 1;
  15. }
  16. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement