Sequence of non-squares: Difference between revisions

Add ABC
(Added Chipmunk Basic)
(Add ABC)
 
(5 intermediate revisions by 3 users not shown)
Line 34:
No squares found
</pre>
 
=={{header|ABC}}==
<syntaxhighlight lang="abc">HOW TO RETURN non.square n:
RETURN n + floor (1/2 + root n)
HOW TO REPORT square n:
REPORT n = (floor root n)**2
 
FOR n IN {1..22}: WRITE non.square n
WRITE /
 
IF NO n IN {1..1000000} HAS square non.square n:
WRITE "No squares occur for n < 1.000.000"</syntaxhighlight>
{{out}}
<pre>2 3 5 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 26 27
No squares occur for n < 1.000.000</pre>
 
=={{header|Ada}}==
Line 399 ⟶ 415:
The functions int, round, floor, ceil are taken from [http://www.pixelbeat.org/scripts/bc here] (int is slightly modified) ([http://www.pixelbeat.org/scripts/ Here] he states the license is GPL).
 
=={{header|BurlesqueBQN}}==
<syntaxhighlight lang="bqn"> NonSquare ← +⟜(⌊0.5+√)
IsSquare ← =⟜⌊√
 
NonSquare 1+↕22
⟨ 2 3 5 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 26 27 ⟩
+´ IsSquare NonSquare 1+↕1e6
0</syntaxhighlight>
 
=={{header|Burlesque}}==
<syntaxhighlight lang="burlesque">
1 22r@{?s0.5?+av?+}[m
Line 1,809 ⟶ 1,833:
2 3 5 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 26 27
No square numbers were generated for n <= 1000000</syntaxhighlight>
 
No loops
<syntaxhighlight lang="matlab">
sum(ismember((1:1:sqrt(1e6-1)).^2,(1:1e6-1) + floor(1/2 + sqrt((1:1e6-1)))))
</syntaxhighlight>
 
=={{header|Maxima}}==
Line 3,204 ⟶ 3,233:
=={{header|Wren}}==
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
System.print("The first 22 numbers in the sequence are:")
2,114

edits