14 lines
340 B
Text
14 lines
340 B
Text
|
|
Happy? := proc( n )
|
||
|
|
if n = 1 then
|
||
|
|
true
|
||
|
|
elif n = 4 then
|
||
|
|
false
|
||
|
|
else
|
||
|
|
local s := SumSqDigits( n );
|
||
|
|
while not ( s in { 1, 4 } ) do
|
||
|
|
s := SumSqDigits( s )
|
||
|
|
end do;
|
||
|
|
evalb( s = 1 )
|
||
|
|
end if
|
||
|
|
end proc:
|