Van Eck sequence: Difference between revisions

Added various BASIC dialects (BASIC256, Chipmunk Basic,GW-BASIC, PureBasic, QBasic, Pure BASIC and Yabasic)
(Added various BASIC dialects (BASIC256, Chipmunk Basic,GW-BASIC, PureBasic, QBasic, Pure BASIC and Yabasic))
Line 984:
 
=={{header|BASIC}}==
{{works with|QBasic}}
<syntaxhighlight lang="basic">10 DEFINT A-Z
20 DIM E(1000)
Line 998 ⟶ 999:
<pre> 0 0 1 0 2 0 2 2 1 6
4 7 30 25 67 225 488 0 10 136</pre>
 
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="qbasic">limite = 1001
dim a(limite) fill 0
 
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
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</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
{{trans|FreeBASIC}}
{{works with|Chipmunk Basic|3.6.4}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">100 cls
110 limite = 1000
120 dim a(limite)
130 '
140 for n = 0 to limite-1
150 for m = n-1 to 0 step -1
160 if a(m) = a(n) then
170 a(n+1) = n-m
180 exit for
190 endif
200 next m
210 next n
220 '
230 print "Secuencia de Van Eck:";chr$(10)
240 print "Primeros 10 terminos: ";
250 for i = 0 to 9
260 print a(i);
270 next i
280 print chr$(10);"Terminos 991 al 1000: ";
290 for i = 990 to 999
300 print a(i);
310 next i
320 end</syntaxhighlight>
 
==={{header|GW-BASIC}}===
{{trans|FreeBASIC}}
{{works with|PC-BASIC|any}}
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">100 CLS
110 L = 1000
120 DIM A(L)
130 FOR N = 0 TO L
140 LET A(N) = 0
150 NEXT N
160 FOR N = 0 TO L-1
170 FOR M = N-1 TO 0 STEP -1
180 IF A(M) = A(N) THEN A(N+1) = N - M : GOTO 200
190 NEXT M
200 NEXT N
210 PRINT "Secuencia de Van Eck:"; CHR$(10)
220 PRINT "Primeros 10 terminos: ";
230 FOR I = 0 TO 9
240 PRINT A(I);
250 NEXT I
260 PRINT CHR$(10); "Terminos 991 al 1000: ";
270 FOR I = 990 TO 999
280 PRINT A(I);
290 NEXT I
300 END</syntaxhighlight>
 
==={{header|PureBasic}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="purebasic">If OpenConsole()
Define.i n, m, i, limite
limite = 1001
Dim a.i(limite)
For n = 0 To limite-1
For m = n-1 To 0 Step -1
If a(m) = a(n)
a(n+1) = n-m
Break
EndIf
Next m
Next n
PrintN("Secuencia de Van Eck:" + #CRLF$)
Print("Primeros 10 terminos: ")
For i = 0 To 9
Print(Str(a(i)) + " ")
Next i
Print(#CRLF$ + "Terminos 991 al 1000: ")
For i = 990 To 999
Print(Str(a(i)) + " ")
Next i
PrintN(#CRLF$ + "Press ENTER to exit" + #CRLF$ ): Input()
CloseConsole()
EndIf</syntaxhighlight>
 
==={{header|QBasic}}===
{{trans|FreeBASIC}}
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">CONST limite = 1000
DIM a(limite)
 
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
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</syntaxhighlight>
 
==={{header|Yabasic}}===
{{trans|FreeBASIC}}
<syntaxhighlight lang="vb">limite = 1001
dim a(limite)
 
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
break
fi
next m
next n
 
print "Secuencia de Van Eck: \n"
print "Primeros 10 terminos: ";
for i = 0 to 9
print a(i), " ";
next i
print "\nTerminos 991 al 1000: ";
for i = 990 to 999
print a(i), " ";
next i
print</syntaxhighlight>
 
=={{header|BCPL}}==
2,122

edits