Anonymous user
Sequence of non-squares: Difference between revisions
Replaced "round.int" by "toInt". Simplified "issqr". Replaced "proc" by "func". Improved output.
Alextretyak (talk | contribs) (Added 11l) |
(Replaced "round.int" by "toInt". Simplified "issqr". Replaced "proc" by "func". Improved output.) |
||
Line 1,609:
=={{header|Nim}}==
<lang nim>import math, strutils
result = newSeq[int]
for i in 1..n:
result[i - 1] = i + i.float.sqrt.
sqrt(float(n)).splitDecimal().floatpart < 1e-7
▲proc issqr(n: int): bool =
echo "Sequence for n = 22:"
echo nosqr(22).join(" ")
echo "\nNo squares were found for n less than 1_000_000."</lang>
▲ assert(not issqr(i))</lang>
{{out}}
<pre>@[2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27]</pre>
|