Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in c please 2 Happy Numbers A happy number is number which eventually reaches 1 when replaced by the sum of the square of each
in c please
2 Happy Numbers A happy number is number which eventually reaches 1 when replaced by the sum of the square of each digit in a recursive fashion. As an example, 13 is a happy number because 12 +32 = 10 12 + 02 = 1 On the other hand 14 is not a happy number because 12 +42 = 17 12 + 72 = 50 52 +0 = 25 22 +52 = 29 22 +92 = 85 42 + 22 = 20 22 + 02 = 4. Write a program that prompts the user to specify the number of digits (n) and finds all n-digit happy numbers. Your code should use the following function bool is Happy(int num); The function receives as input an integer num and returns true if the number is happy and false if the number is sad. Sample Output: Enter the number of digits: 2 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, Enter the number of digits: 3 100, 103, 109, 129, 130, 133, 139, 167, 176, 188, 190, 192, 193, 203, 208, 219, 226, 230, 236, 239, 262, 263, 280, 291, 293, 301, 302, 310, 313, 319, 320, 326, 329, 331, 338, 356, 362, 365, 367, 368, 376, 379, 383, 386, 391, 392, 397, 404, 409, 440, 446, 464, 469, 478, 487, 490, 496, 536, 556, 563, 565, 566, 608, 617, 622, 623, 632, 635, 637, 638, 644, 649, 653, 655, 656, 665, 671, 673, 680, 683, 694, 700, 709, 716, 736, 739, 748, 761, 763, 784, 790, 793, 802, 806, 818, 820, 833, 836, 847, 860, 863, 874, 881, 888, 899, 901, 904, 907, 910, 912, 913, 921, 923, 931, 932, 937, 940, 946, 964, 970, 973, 989, 998Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started