Happy numbers: Difference between revisions

(→‎{{header|ALGOL W}}: another tweak)
Line 476:
% containing 4 (see the Wikipedia article) - the Algol 68 sample %
% also uses this %
integer v, dSum, d;
v := abs n;
dSumif :=v 0;> 1 then begin
if v not = 0 then begin
while begin
dSum := 0;
while v not = 0 do begin
integer d;
d := v rem 10;
v := v div 10;
dSum := dSum + ( d * d )
end while_v_ne_0 ;
dSum notv := 1 and dSum not = 4;
end v not = 1 and v not = 4
end do begin end
v := dSum
end while_not_happy_and_not_looping
end if_v_ne_0 ;
dSumv = 1
end isHappy ;
begin % find the first 8 happy numbers %
3,038

edits