26 lines
606 B
Plaintext
26 lines
606 B
Plaintext
procedure main()
|
|
|
|
write("Non-cube Squares (21st to 30th):")
|
|
every (k := 0, s := noncubesquares()) do
|
|
if(k +:= 1) > 30 then break
|
|
else write(20 < k," : ",s)
|
|
end
|
|
|
|
procedure mthpower(m) #: generate i^m for i = 0,1,...
|
|
while (/i := 0) | (i +:= 1) do suspend i^m
|
|
end
|
|
|
|
procedure noncubesquares() #: filter for squares that aren't cubes
|
|
cu := create mthpower(3) # co-expressions so that we can
|
|
sq := create mthpower(2) # ... get our results where we need
|
|
|
|
repeat {
|
|
if c === s then ( c := @cu , s := @sq )
|
|
else if s > c then c := @cu
|
|
else {
|
|
suspend s
|
|
s := @sq
|
|
}
|
|
}
|
|
end
|