We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e1b99c1 + 0373ff5 commit e543a19Copy full SHA for e543a19
1 file changed
math/Happy-Number/Happy-Number.py
@@ -0,0 +1,15 @@
1
+print("🔢 Happy Number Checker 🔢")
2
+print("🎯 A happy number is a number which eventually reaches 1 when replaced repeatedly by the sum of the square of its digits.\n")
3
+
4
+N = int(input("➡️ Enter a number: "))
5
6
+seen = set()
7
+num = N
8
+while num != 1 and num not in seen:
9
+ seen.add(num)
10
+ num = sum((int(digit) ** 2) for digit in str(num))
11
12
+if (num == 1):
13
+ print(f"🔍 {N} is a happy number! ✅")
14
+else:
15
+ print(f"🔍 {N} is not a happy number. ❌")
0 commit comments