Smallest square that begins with n: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: use pow10) |
m (→{{header|Julia}}: shorten) |
||
Line 1,783: | Line 1,783: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<syntaxhighlight lang="julia">function |
<syntaxhighlight lang="julia">function smsq(n = 49) |
||
results = zeros(Int, n) |
|||
found, square, delta = 0, 1, 3 |
|||
while found < n |
|||
p_string = string.(p_int) |
|||
k = square |
|||
while k > 0 |
|||
if k <= n && results[k] == 0 |
|||
results[k] = square |
|||
found += 1 |
|||
⚫ | |||
numfound += 1 |
|||
end |
end |
||
⚫ | |||
end |
end |
||
square += delta |
|||
delta += 2 |
|||
for p in enumerate(res) |
|||
⚫ | |||
end |
|||
end |
|||
break |
|||
end |
|||
end |
end |
||
return |
return results |
||
end |
end |
||
⚫ | |||
squaresstartingupto(49) |
|||
</syntaxhighlight>{{out}} |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |