Happy numbers: Difference between revisions
→{{header|ALGOL W}}: Simplified
(→{{header|ALGOL W}}: Slightly simpler version) |
(→{{header|ALGOL W}}: Simplified) |
||
Line 473:
logical procedure isHappy ( integer value n ) ;
begin
%
% containing 4 (see the Wikipedia article) - the Algol 68 sample %
% also uses this %
integer v, dSum;
v := abs n;
while begin
Line 486:
dSum := dSum + ( d * d )
end while_v_ne_0 ;
dSum not = 1 and dSum not
end
do begin
end while_not_happy_and_not_looping ;
dSum = 1
|