Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Happy-numbers/Salmon/happy-numbers.salmon
Normal file
29
Task/Happy-numbers/Salmon/happy-numbers.salmon
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
variable happy_count := 0;
|
||||
outer:
|
||||
iterate(x; [1...+oo])
|
||||
{
|
||||
variable seen := <<(* --> false)>>;
|
||||
variable now := x;
|
||||
while (true)
|
||||
{
|
||||
if (seen[now])
|
||||
{
|
||||
if (now == 1)
|
||||
{
|
||||
++happy_count;
|
||||
print(x, " is happy.\n");
|
||||
if (happy_count == 8)
|
||||
break from outer;;
|
||||
};
|
||||
break;
|
||||
};
|
||||
seen[now] := true;
|
||||
variable new := 0;
|
||||
while (now != 0)
|
||||
{
|
||||
new += (now % 10) * (now % 10);
|
||||
now /::= 10;
|
||||
};
|
||||
now := new;
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue