+ 16
😁😀Challenge: Happy numbers! 😀😁
A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy (or sad) numbers. A happy prime is a number that is both happy and prime. Find both happy numbers and happy prim
11 ответов
+ 15
My Code: Using Python ☆
https://code.sololearn.com/cSbKDxaUE1SZ/?ref=app
The best thing about it (objectively talking) is the proper handling of the endless loop for the unhappy numbers (No Limit Error)
However, I didn't test it that much, so in case of an error or bug please tell me ^^
Hope u Like it ♡
+ 8
this code checks whether a number is happy / happy-prime or not........
https://code.sololearn.com/cBcZ6p93elpm/?ref=app
+ 8
Here's my try:
https://code.sololearn.com/WfUfsKoM0JD6/?ref=app
+ 7
Here you go. Very little code.
Edit: Now prints both happy numbers and happy primes, thanks Noob.
https://code.sololearn.com/c8X21fFizgW3/?ref=app
+ 4
Here is my code
https://code.sololearn.com/c5Lly4kiE98j/?ref=app
All fixed now.
+ 2
I already posted this:
https://www.sololearn.com/discuss/583252/?ref=app
+ 2
My code using java:
https://code.sololearn.com/cz59ShKT9tIZ
If there any bugs or else please tell me.
Hope you like it. :)
+ 2
one day unhappy numbers are going to group up and kill all happy numbers.
https://code.sololearn.com/cYZX3Z6H8RH4/?ref=app
+ 1
@vari93 it lacks the happy numbers (non primes) though..
0
@Noob Oh lol, I totally spaced on that, just a sec