Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Happy-numbers/Picat/happy-numbers.picat
Normal file
25
Task/Happy-numbers/Picat/happy-numbers.picat
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
go =>
|
||||
println(happy_len(8)).
|
||||
|
||||
happy(N) =>
|
||||
S = [N],
|
||||
Happy = 1,
|
||||
while (Happy == 1, N > 1)
|
||||
N := sum([to_integer(I)**2 : I in N.to_string()]),
|
||||
if member(N,S) then
|
||||
Happy := 0
|
||||
else
|
||||
S := S ++ [N]
|
||||
end
|
||||
end,
|
||||
Happy == 1.
|
||||
|
||||
happy_len(Limit) = S =>
|
||||
S = [],
|
||||
N = 1,
|
||||
while (S.length < Limit)
|
||||
if happy(N) then
|
||||
S := S ++ [N]
|
||||
end,
|
||||
N := N + 1
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue