10 lines
187 B
Text
10 lines
187 B
Text
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;
|