Van Eck sequence: Difference between revisions

Added XBasic and grouping BASICS dialects
(Added various BASIC dialects (BASIC256, Chipmunk Basic,GW-BASIC, PureBasic, QBasic, Pure BASIC and Yabasic))
(Added XBasic and grouping BASICS dialects)
Line 1,051:
310 next i
320 end</syntaxhighlight>
 
==={{header|Craft Basic}}===
<syntaxhighlight lang="basic">define limit = 1000
 
dim list[limit]
 
print "calculating van eck sequence..."
 
for n = 0 to limit - 1
 
for m = n - 1 to 0 step -1
 
if list[m] = list[n] then
 
let c = n + 1
let list[c] = n - m
 
break m
 
endif
 
wait
 
next m
 
next n
 
print "first 10 terms: "
 
for i = 0 to 9
 
print list[i]
 
next i
 
print "terms 991 to 1000: "
 
for i = 990 to 999
 
print list[i]
 
next i</syntaxhighlight>
{{out| Output}}<pre>calculating van eck sequence...
first 10 terms: 0 0 1 0 2 0 2 2 1 6
terms 991 to 1000: 4 7 30 25 67 225 488 0 10 136 </pre>
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="vb">Const limite = 1000
 
Dim As Integer a(limite), n, m, i
 
For n = 0 To limite-1
For m = n-1 To 0 Step -1
If a(m) = a(n) Then a(n+1) = n-m: Exit For
Next m
Next n
 
Print "Secuencia de Van Eck:" &Chr(10)
Print "Primeros 10 terminos: ";
For i = 0 To 9
Print a(i) &" ";
Next i
Print Chr(10) & "Terminos 991 al 1000: ";
For i = 990 To 999
Print a(i) &" ";
Next i
End</syntaxhighlight>
{{out}}
<pre>Secuencia de Van Eck:
 
Primeros 10 terminos: 0 0 1 0 2 0 2 2 1 6
Terminos 991 al 1000: 4 7 30 25 67 225 488 0 10 136</pre>
 
==={{header|GW-BASIC}}===
Line 1,136 ⟶ 1,208:
NEXT i
END</syntaxhighlight>
 
==={{header|XBasic}}===
{{trans|FreeBASIC}}
{{works with|Windows XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "Van Eck sequence"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
l = 1000
DIM a[l]
FOR n = 0 TO l-1
FOR m = n-1 TO 0 STEP -1
IF a[m] = a[n] THEN
a[n+1] = n-m
EXIT FOR
END IF
NEXT m
NEXT n
PRINT "Secuencia de Van Eck:"; CHR$(10)
PRINT "Primeros 10 terminos: ";
FOR i = 0 TO 9
PRINT a[i]; " ";
NEXT i
PRINT CHR$(10); "Terminos 991 al 1000: ";
FOR i = 990 TO 999
PRINT a[i]; " ";
NEXT i
END FUNCTION
END PROGRAM</syntaxhighlight>
 
==={{header|Yabasic}}===
Line 1,501 ⟶ 1,604:
<pre>0 0 1 0 2 0 2 2 1 6
4 7 30 25 67 225 488 0 10 136</pre>
 
=={{header|Craft Basic}}==
<syntaxhighlight lang="basic">define limit = 1000
 
dim list[limit]
 
print "calculating van eck sequence..."
 
for n = 0 to limit - 1
 
for m = n - 1 to 0 step -1
 
if list[m] = list[n] then
 
let c = n + 1
let list[c] = n - m
 
break m
 
endif
 
wait
 
next m
 
next n
 
print "first 10 terms: "
 
for i = 0 to 9
 
print list[i]
 
next i
 
print "terms 991 to 1000: "
 
for i = 990 to 999
 
print list[i]
 
next i</syntaxhighlight>
{{out| Output}}<pre>
calculating van eck sequence...
first 10 terms: 0 0 1 0 2 0 2 2 1 6
terms 991 to 1000: 4 7 30 25 67 225 488 0 10 136
</pre>
 
=={{header|D}}==
Line 1,783 ⟶ 1,839:
<pre> 0 0 1 0 2 0 2 2 1 6
4 7 30 25 67 225 488 0 10 136</pre>
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">
Const limite = 1000
 
Dim As Integer a(limite), n, m, i
 
For n = 0 To limite-1
For m = n-1 To 0 Step -1
If a(m) = a(n) Then a(n+1) = n-m: Exit For
Next m
Next n
 
Print "Secuencia de Van Eck:" &Chr(10)
Print "Primeros 10 terminos: ";
For i = 0 To 9
Print a(i) &" ";
Next i
Print Chr(10) & "Terminos 991 al 1000: ";
For i = 990 To 999
Print a(i) &" ";
Next i
End
</syntaxhighlight>
{{out}}
<pre>
Secuencia de Van Eck:
 
Primeros 10 terminos: 0 0 1 0 2 0 2 2 1 6
Terminos 991 al 1000: 4 7 30 25 67 225 488 0 10 136
</pre>
 
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Van_Eck_sequence}}
 
2,135

edits