#include <stdbool.h> int change(int x) { int sum = 0; while(x > 0) { int j = x % 10; sum += j * j; x /= 10; } return sum; } bool happynum(int n ) { // write code here while(n > 9) n = change(n); if (n == 1) return true; else return false; }
#include <stdbool.h> int change(int x) { int sum = 0; while(x > 0) { int j = x % 10; sum += j * j; x /= 10; } return sum; } bool happynum(int n ) { // write code here while(n > 9) n = change(n); if (n == 1) return true; else return false; }