Sequence of non-squares: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
m (→‎{{header|REXX}}: added whitespace.)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 125:
Loop 1000000
x := A_Index + floor(0.5 + sqrt(A_Index)), s += x = round(sqrt(x))**2
Msgbox Number of bad squares = %s% ; 0</lang>
 
=={{header|AWK}}==
Line 1,280:
 
</pre>
 
=={{header|Mathematica}}==
<lang Mathematica>nonsq = (# + Floor[0.5 + Sqrt[#]]) &;
Line 1,656 ⟶ 1,657:
{{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>
 
=={{header|Perl 6}}==
 
{{works with|Rakudo|2016.07}}
<lang perl6>sub nth-term (Int $n) { $n + round sqrt $n }
 
# Print the first 22 values of the sequence
say (nth-term $_ for 1 .. 22);
 
# Check that the first million values of the sequence are indeed non-square
for 1 .. 1_000_000 -> $i {
say "Oops, nth-term($i) is square!" if (sqrt nth-term $i) %% 1;
}</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>
 
=={{header|Phix}}==
Line 2,081 ⟶ 2,066:
#f
</pre>
 
=={{header|Perl 6Raku}}==
(formerly Perl 6)
 
{{works with|Rakudo|2016.07}}
<lang perl6>sub nth-term (Int $n) { $n + round sqrt $n }
 
# Print the first 22 values of the sequence
say (nth-term $_ for 1 .. 22);
 
# Check that the first million values of the sequence are indeed non-square
for 1 .. 1_000_000 -> $i {
say "Oops, nth-term($i) is square!" if (sqrt nth-term $i) %% 1;
}</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>
 
=={{header|REXX}}==
Line 2,420 ⟶ 2,422:
no squares found
</pre>
 
=={{header|VBA}}==
<lang vb>
Line 2,444 ⟶ 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,
0 squares less than 1000000</pre>
 
=={{header|XLISP}}==
<lang lisp>(defun non-square (n)
10,333

edits