Smallest square that begins with n: Difference between revisions

Add CLU
(Add CLU)
Line 505:
48 484 22
49 49 7</pre>
 
=={{header|CLU}}==
<lang clu>begins_with = proc (n, s: int) returns (bool)
while n>s do n := n/10 end
return(n=s)
end begins_with
 
smallest_square = proc (n: int) returns (int)
sq: int := 1
while ~begins_with(sq**2, n) do sq := sq + 1 end
return(sq**2)
end smallest_square
 
start_up = proc ()
po: stream := stream$primary_output()
col: int := 0
for i: int in int$from_to(1,49) do
stream$putright(po, int$unparse(smallest_square(i)), 7)
col := col + 1
if col=10 then
col := 0
stream$putl(po, "")
end
end
stream$putl(po, "")
end start_up</lang>
{{out}}
<pre> 1 25 36 4 529 64 729 81 9 100
1156 121 1369 144 1521 16 1764 1849 196 2025
2116 225 2304 2401 25 2601 2704 289 2916 3025
3136 324 3364 3481 35344 36 3721 3844 3969 400
41209 4225 4356 441 45369 4624 4761 484 49</pre>
 
=={{header|COBOL}}==
2,126

edits