Sequence of non-squares: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
(Added Wren) |
||
Line 2,447: | Line 2,447: | ||
<pre>values for n in the range 1 to 22 : 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, |
<pre>values for n in the range 1 to 22 : 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, |
||
0 squares less than 1000000</pre> |
0 squares less than 1000000</pre> |
||
=={{header|Wren}}== |
|||
{{libheader|Wren-fmt}} |
|||
<lang ecmascript>import "/fmt" for Fmt |
|||
System.print("The first 22 numbers in the sequence are:") |
|||
System.print(" n term") |
|||
for (n in 1...1e6) { |
|||
var s = n + (0.5 + n.sqrt).floor |
|||
var ss = s.sqrt.round |
|||
if (ss * ss == s) { |
|||
Fmt.print("The $r number in the sequence $d = $d x $d is a square.", n, s, ss, ss) |
|||
return |
|||
} |
|||
if (n <= 22) Fmt.print(" $2d $2d", n, s) |
|||
} |
|||
System.print("\nNo squares were found in the first 999,999 terms.")</lang> |
|||
{{out}} |
|||
<pre> |
|||
The first 22 numbers in the sequence are: |
|||
n term |
|||
1 2 |
|||
2 3 |
|||
3 5 |
|||
4 6 |
|||
5 7 |
|||
6 8 |
|||
7 10 |
|||
8 11 |
|||
9 12 |
|||
10 13 |
|||
11 14 |
|||
12 15 |
|||
13 17 |
|||
14 18 |
|||
15 19 |
|||
16 20 |
|||
17 21 |
|||
18 22 |
|||
19 23 |
|||
20 24 |
|||
21 26 |
|||
22 27 |
|||
No squares were found in the first 999,999 terms. |
|||
</pre> |
|||
=={{header|XLISP}}== |
=={{header|XLISP}}== |