Smallest square that begins with n: Difference between revisions

(Added Go)
Line 60:
3136 324 3364 3481 35344 36 3721 3844 3969 400
41209 4225 4356 441 45369 4624 4761 484 49
</pre>
 
=={{header|Phix}}==
<lang Phix>constant lim = 49
sequence res = repeat(0,lim)
integer n = 1, found = 0
while found<lim do
integer n2 = n*n
while n2 do
if n2<=lim and res[n2]=0 then
found += 1
res[n2] = n
end if
n2 = floor(n2/10)
end while
n += 1
end while
res = columnize({tagset(lim),sq_power(res,2),apply(true,sprintf,{{"(%d^2)"},res})})
printf(1,"Smallest squares that begin with 1..%d:\n%s\n",
{lim,join_by(apply(true,sprintf,{{"%2d: %5d %-8s"},res}),1,5)})</lang>
{{out}}
<pre>
Smallest squares that begin with 1..49:
1: 1 (1^2) 2: 25 (5^2) 3: 36 (6^2) 4: 4 (2^2) 5: 529 (23^2)
6: 64 (8^2) 7: 729 (27^2) 8: 81 (9^2) 9: 9 (3^2) 10: 100 (10^2)
11: 1156 (34^2) 12: 121 (11^2) 13: 1369 (37^2) 14: 144 (12^2) 15: 1521 (39^2)
16: 16 (4^2) 17: 1764 (42^2) 18: 1849 (43^2) 19: 196 (14^2) 20: 2025 (45^2)
21: 2116 (46^2) 22: 225 (15^2) 23: 2304 (48^2) 24: 2401 (49^2) 25: 25 (5^2)
26: 2601 (51^2) 27: 2704 (52^2) 28: 289 (17^2) 29: 2916 (54^2) 30: 3025 (55^2)
31: 3136 (56^2) 32: 324 (18^2) 33: 3364 (58^2) 34: 3481 (59^2) 35: 35344 (188^2)
36: 36 (6^2) 37: 3721 (61^2) 38: 3844 (62^2) 39: 3969 (63^2) 40: 400 (20^2)
41: 41209 (203^2) 42: 4225 (65^2) 43: 4356 (66^2) 44: 441 (21^2) 45: 45369 (213^2)
46: 4624 (68^2) 47: 4761 (69^2) 48: 484 (22^2) 49: 49 (7^2)
</pre>
 
7,820

edits