Details
A happy number is defined by the following Sequence: Starting 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 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 sad numbers.
For example, 19 is happy, as the associated Sequence is:
12 + 92 = 82
82 + 22 = 68
62 + 82 = 100
12 + 02 + 02 = 1.
Print all the happy numbers from 1 to
200
inclusive, each on their own line.
Variants:
Happy Numbers (Long)
External links:
OEIS A007770 ,
Rosetta Code ,
Wikipedia
Copy Answer
Copied
05AB1E is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
ALGOL 68 is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
APL is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Arturo is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Befunge is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
BQN is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
CJam is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
CoffeeScript is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Egel is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Erlang is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Fennel is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Groovy is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Harbour is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Hare is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Haxe is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Hush is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Hy is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
iogii is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Odin is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Picat is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Racket is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Rebol is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Rexx is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Scala is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Squirrel is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Uiua is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .
Vyxal is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue .