Fibonacci sequence: Difference between revisions
Content deleted Content added
→{{header|Commodore BASIC}}: Add support for negative indexes and showing a range instead of just single item. |
|||
Line 1,429:
==={{header|Commodore BASIC}}===
<lang basic>100 PRINT CHR$(147); CHR$(18); "**** FIBONACCI GENERATOR ****"
120 IF N1 > N2 THEN T=N1: N1=N2: N2=T
30 FOR K=1 TO N▼
150 : IF S > 0 THEN T=A+B: A=B: B=T
160 : IF S < 0 THEN T=B-A: B=A: A=T
80 PRINT N1</lang>▼
180 PRINT
190 PRINT STR$(A); : REM STR$() PREVENTS TRAILING SPACE
200 IF N2 = N1 THEN 250
220 : T=A+B: A=B: B=T
230 : PRINT ","STR$(A);
240 NEXT I
{{Out}}
<pre>**** FIBONACCI GENERATOR ****
MIN, MAX? -6,6
-8, 5,-3, 2,-1, 1, 0, 1, 1, 2, 3, 5, 8
READY.</pre>
==={{header|Integer BASIC}}===
|