Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Happy-numbers/Potion/happy-numbers.potion
Normal file
20
Task/Happy-numbers/Potion/happy-numbers.potion
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
sqr = (n): n * n.
|
||||
|
||||
isHappy = (n) :
|
||||
loop :
|
||||
if (n == 1): return true.
|
||||
if (n == 4): return false.
|
||||
sum = 0
|
||||
n = n string
|
||||
n length times (i): sum = sum + sqr(n(i) number integer).
|
||||
n = sum
|
||||
.
|
||||
.
|
||||
|
||||
firstEight = ()
|
||||
i = 0
|
||||
while (firstEight length < 8) :
|
||||
i++
|
||||
if (isHappy(i)): firstEight append(i).
|
||||
.
|
||||
firstEight string print
|
||||
Loading…
Add table
Add a link
Reference in a new issue