_TITLE "Recaman Sequence" 'B+ 2019-02-18
'reference and thanks:
' [youtube]https://www.youtube.com/watch?v=FGC5TdIiT9U[/youtube]
'prep sound array
DIM s
(0 TO 41) '6 * 7 mod 42 ' c d e f g a b
s(0) = 65: s(1) = 73: s(2) = 82: s(3) = 87: s(4) = 98: s(5) = 110: s(6) = 123
s(7) = 131: s(8) = 147: s(9) = 165: s(10) = 175: s(11) = 196: s(12) = 220: s(13) = 247
s(14) = 262: s(15) = 294: s(16) = 330: s(17) = 349: s(18) = 392: s(19) = 440: s(20) = 494
s(21) = 523: s(22) = 587: s(23) = 659: s(24) = 698: s(25) = 784: s(26) = 880: s(27) = 988
s(28) = 1047: s(29) = 1175: s(30) = 1318: s(31) = 1397: s(32) = 1568: s(33) = 1760: s(34) = 1976
s(35) = 2093: s(36) = 2349: s(37) = 2637: s(38) = 2794: s(39) = 3136: s(40) = 3520: s(41) = 3951
'draw a number line spacing integers by SP
CY = ymax / 2
SP = 5 'so 1200/sp = 240 numbers on a numberline
DIM n
(0 TO 16000) 'save places where number is used
interval = 1
current = 0
n(current) = -1 'we've been here already!
' !!! The rule is to go back if (current position - interval) is not taken and is >= 0, otherwise go forward.
' The interval is increased by one after each hop.
LINE (0, 0)-(200, 30), _RGB32(0, 0, 0) ' clean out old message LOCATE 1, 1:
PRINT "Interval:"; interval
'report interval or hop number
R = interval / 2 'for radius of hop drawing
'alternate hops with semi circles
start
= _PI: fini
= 0 'semi circle start and end over the line start
= 0: fini
= _PI 'semi circle start and end under the line
test = current - interval 'test against our Rule
'draw current to current + interval
CIRCLE (SP
* (current
+ R
), CY
), R
* SP
, , start
, fini
current = current + interval
n(current) = -1 'we've been here
'draw current to current + interval
CIRCLE (SP
* (current
+ R
), CY
), R
* SP
, , start
, fini
current = current + interval
n(current) = -1 'we've been here
'draw back semi current - interval
CIRCLE (SP
* (current
- R
), CY
), R
* SP
, , start
, fini
current = test
n(current) = -1 'we've been here
interval = interval + 1
_LIMIT 6 '<<< however fast you want 1, 10, 100 LOOP UNTIL q
OR interval
= 3001 'good place to stop for this graph
PRINT "What numbers are left after 3000 hops? ":
' 1* D#1 ...... 39 G3 ....... 196 A#5 ...... 932
' E1 ....... 41 G#3 ...... 208 B5 ....... 988
' F1 ....... 44 A3 ....... 220 6* C6 ....... 1047
' F#1 ...... 46 A#3 ...... 233 C#6 ...... 1109
' G1 ....... 49 B3 ....... 247 D6 ....... 1175
' G#1 ...... 51 4* C4 ....... 262 D#6 ...... 1245
' A1 ....... 55 C#4 ...... 277 E6 ....... 1318
' A#1 ...... 58 D4 ....... 294 F6 ....... 1397
' B1 ....... 62 D#4 ...... 311 F#6 ...... 1480
' 2* C2 ....... 65 E4 ....... 330 G6 ....... 1568
' C#2 ...... 69 F4 ....... 349 G# ....... 1661
' D2 ....... 73 F#4 ...... 370 A6 ....... 1760
' D#2 ...... 78 G4 ....... 392 A#6 ...... 1865
' E2 ....... 82 G#4 ...... 415 B6 ....... 1976
' F2 ....... 87 A4 ....... 440 7* C7 ....... 2093
' F#2 ...... 92 A# ....... 466 C#7 ...... 2217
' G2 ....... 98 B4 ....... 494 D7 ....... 2349
' G#2 ...... 104 5* C5 ....... 523 D#7 ...... 2489
' A2 ....... 110 C#5 ...... 554 E7 ....... 2637
' A#2 ...... 117 D5 ....... 587 F7 ....... 2794
' B2 ....... 123 D#5 ...... 622 F#7 ...... 2960
' 3* C3 ....... 131 E5 ....... 659 G7 ....... 3136
' C#3 ...... 139 F5 ....... 698 G#7 ...... 3322
' D3 ....... 147 F#5 ...... 740 A7 ....... 3520
' D#3 ...... 156 G5 ....... 784 A#7 ...... 3729
' E3 ....... 165 G#5 ...... 831 B7 ....... 3951
' F3 ....... 175 A5 ....... 880 8* C8 ....... 4186
' F#3 ...... 185