Sequence of non-squares: Difference between revisions

Add CLU
(Add Red)
(Add CLU)
Line 459:
 
(defn verify [] (not-any? square? (map nonsqr (range 1 1000000))) )</lang>
 
=={{header|CLU}}==
<lang clu>non_square = proc (n: int) returns (int)
return(n + real$r2i(0.5 + real$i2r(n)**0.5))
end non_square
 
is_square = proc (n: int) returns (bool)
return(n = real$r2i(real$i2r(n)**0.5))
end is_square
 
start_up = proc()
po: stream := stream$primary_output()
for n: int in int$from_to(1, 22) do
stream$puts(po, int$unparse(non_square(n)) || " ")
end
stream$putl(po, "")
begin
for n: int in int$from_to(1, 1000000) do
if is_square(non_square(n)) then exit square(n) end
end
stream$putl(po, "No squares found up to 1000000.")
end
except when square(n: int):
stream$putl(po, "Found square " || int$unparse(non_square(n))
|| " at n = " || int$unparse(n))
end
end start_up </lang>
{{out}}
<pre>2 3 5 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 26 27
No squares found up to 1000000.</pre>
 
=={{header|CoffeeScript}}==
2,114

edits