Smallest square that begins with n: Difference between revisions
Content added Content deleted
(julia example) |
SqrtNegInf (talk | contribs) (Added Perl) |
||
Line 138: | Line 138: | ||
</pre> |
</pre> |
||
=={{header|Perl}}== |
|||
<lang perl>use strict; |
|||
use warnings; |
|||
use constant Inf => 10e12; # arbitrarily large value |
|||
for my $n (1..49) { |
|||
do { printf "%2d: %3d^2 = %5d\n", $n, $_, $_**2 and last if $_**2 =~ /^$n/ } for 1..Inf |
|||
}</lang> |
|||
{{out}} |
|||
<pre> 1: 1^2 = 1 |
|||
2: 5^2 = 25 |
|||
3: 6^2 = 36 |
|||
4: 2^2 = 4 |
|||
5: 23^2 = 529 |
|||
6: 8^2 = 64 |
|||
7: 27^2 = 729 |
|||
8: 9^2 = 81 |
|||
9: 3^2 = 9 |
|||
10: 10^2 = 100 |
|||
11: 34^2 = 1156 |
|||
12: 11^2 = 121 |
|||
13: 37^2 = 1369 |
|||
14: 12^2 = 144 |
|||
26: 51^2 = 2601 |
|||
27: 52^2 = 2704 |
|||
28: 17^2 = 289 |
|||
29: 54^2 = 2916 |
|||
30: 55^2 = 3025 |
|||
31: 56^2 = 3136 |
|||
32: 18^2 = 324 |
|||
33: 58^2 = 3364 |
|||
34: 59^2 = 3481 |
|||
35: 188^2 = 35344 |
|||
36: 6^2 = 36 |
|||
37: 61^2 = 3721 |
|||
38: 62^2 = 3844 |
|||
39: 63^2 = 3969 |
|||
40: 20^2 = 400 |
|||
41: 203^2 = 41209 |
|||
42: 65^2 = 4225 |
|||
43: 66^2 = 4356 |
|||
44: 21^2 = 441 |
|||
45: 213^2 = 45369 |
|||
46: 68^2 = 4624 |
|||
47: 69^2 = 4761 |
|||
48: 22^2 = 484 |
|||
49: 7^2 = 49</pre> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |