Smallest square that begins with n: Difference between revisions

Add Draco
(Add MAD)
(Add Draco)
Line 699:
484
49</pre>
 
=={{header|Draco}}==
<lang draco>proc nonrec prefix(word a, b) bool:
while a > b do a := a/10 od;
a = b
corp
 
proc nonrec findPrefixSquare(word n) word:
word sq, sqn;
sqn := 1;
while
sq := sqn * sqn;
not prefix(sq, n)
do
sqn := sqn + 1
od;
sq
corp
 
proc nonrec main() void:
word i, col;
col := 0;
for i from 1 upto 49 do
write(findPrefixSquare(i):7);
col := col + 1;
if col = 10 then
col := 0;
writeln()
fi
od
corp</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|Excel}}==
2,126

edits