45 lines
999 B
Plaintext
45 lines
999 B
Plaintext
Generate: procedure options (main); /* 27 October 2013 */
|
|
declare j fixed binary;
|
|
declare r fixed binary;
|
|
|
|
/* Ignore the first 20 values */
|
|
do j = 1 to 20;
|
|
/* put edit (filter() ) (f(6)); */
|
|
r = filter ();
|
|
end;
|
|
put skip;
|
|
do j = 1 to 10;
|
|
put edit (filter() ) (f(6));
|
|
end;
|
|
|
|
/* filters out cubes from the result of the square generator. */
|
|
filter: procedure returns (fixed binary);
|
|
declare n fixed binary static initial (-0);
|
|
declare (i, j, m) fixed binary;
|
|
|
|
do while ('1'b);
|
|
m = squares();
|
|
r = 0;
|
|
do j = 1 to m;
|
|
if m = cubes() then go to ignore;
|
|
end;
|
|
return (m);
|
|
ignore:
|
|
end;
|
|
end filter;
|
|
|
|
squares: procedure returns (fixed binary);
|
|
declare i fixed binary static initial (-0);
|
|
|
|
i = i + 1;
|
|
return (i**2);
|
|
end squares;
|
|
|
|
cubes: procedure returns (fixed binary);
|
|
|
|
r = r + 1;
|
|
return (r**3);
|
|
end cubes;
|
|
|
|
end Generate;
|