Smallest square that begins with n
1..49 -> map {|n|
[n, n.isqrt..Inf -> first {|j| Str(j**2).starts_with(n) }]
}.slices(5).each {|a|
say a.map { '%2d: %5d %-8s' % (_[0], _[1]**2, "(#{_[1]}^2)") }.join(' ')
}
Output:
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)
Last updated