-
Notifications
You must be signed in to change notification settings - Fork 0
rapala61/Challenge2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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 numbers (or sad numbers). For example: 7 is a happy number, as 7²=49, 4²+9²=16+81=97, 9²+7²=81+49=130, 1²+3²+0²=1+9+0=10, and 1²+0²=1+0=1. 17 is not a happy number, as 1²+7²=1+49=50, 5²+0²=25+0=25, 2²+5²=4+25=29, 2²+9²=4+81=85, 8²+5²=64+25=89, 8²+9²=64+81=145, 1²+4²+5²=1+16+25=42, 4²+2²=16+4=20, 2²+0²=4+0=4, 4²=16, 1²+6²=1+36=37, 3²+7²=9+49=58, and 5²+8²=25+64=89, which forms a loop.
About
Happy numbers
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published