Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Happy-numbers/SETL/happy-numbers-1.setl
Normal file
10
Task/Happy-numbers/SETL/happy-numbers-1.setl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
proc is_happy(n);
|
||||
s := [n];
|
||||
while n > 1 loop
|
||||
if (n := +/[val(i)**2: i in str(n)]) in s then
|
||||
return false;
|
||||
end if;
|
||||
s with:= n;
|
||||
end while;
|
||||
return true;
|
||||
end proc;
|
||||
8
Task/Happy-numbers/SETL/happy-numbers-2.setl
Normal file
8
Task/Happy-numbers/SETL/happy-numbers-2.setl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
happy := [];
|
||||
n := 1;
|
||||
until #happy = 8 loop
|
||||
if is_happy(n) then happy with:= n; end if;
|
||||
n +:= 1;
|
||||
end loop;
|
||||
|
||||
print(happy);
|
||||
1
Task/Happy-numbers/SETL/happy-numbers-3.setl
Normal file
1
Task/Happy-numbers/SETL/happy-numbers-3.setl
Normal file
|
|
@ -0,0 +1 @@
|
|||
print([n : n in [1..100] | is_happy(n)](1..8));
|
||||
Loading…
Add table
Add a link
Reference in a new issue