Answered step by step
Verified Expert Solution
Link Copied!

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 pleaseimage text in transcribed

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, 998

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions

Question

What is risk aversion and how do we know investors are risk averse?

Answered: 1 week ago