+ 4
CHALLENGE: HAPPY NUMBERS!!!!!
Start with any positive integer, replace the number by the sum of the squares of its digits in base-ten, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that include number 4. Those numbers for which this process ends in 1 are called happy numbers, others are unhappy or sad numbers. Examples: 208 -> 2*2 + 8*8 = 68 -> 6*6 + 8*8 = 100 -> 1*1 = 1 ---> HAPPY NUMBER :) 145 -> 1*1 + 4*4 + 5*5 = 42 -> 4*4 + 2*2 = 20 -> 2*2 = 4 ---> SAD NUMBER :( Write a program that gets a number and says if it is happy or not.
7 Respostas
+ 2
My solution:
https://code.sololearn.com/cwoA9YMj5Svj/?ref=app
+ 20
https://code.sololearn.com/cQrj6XdvguyT/?ref=app
+ 7
Here's my C# implementation! ✌
No LINQ this time and I gave credit to Amrit in the code since he's the one that propose the same challenge before this. Enjoy~ ❤
https://code.sololearn.com/cbB504rypHIG/?ref=app
+ 4
https://www.sololearn.com/discuss/583252/?ref=app
Posted earlier by me...
+ 3
I think this challenge is around plus I had not resolved yet so here my practice on python ☺ https://code.sololearn.com/cymJJVP2fNp8/#py
0
My java solution based on easy method and loops
https://code.sololearn.com/cg1LLvk0hJN5/#java
0
Very nice & knowledgeable post all features are defined in a good way for more detail visit https://bit.ly/2WapnD4 thanks