Code: (Select All)
' Audio presentation of numbers.bas for QB64 fork (B+=MGA) 2017-09-20
' Using Owens 2X Deluxe Mod
_Title "Audio Presentation of Numbers as Primes = 0 or First Factor"
_Define A-Z As _INTEGER64
Option Base 1
Common Shared ff(), topN
topN = 1000000
testlimitN = Sqr(topN)
Dim ff(topN + 30)
For i = 0 To topN Step 30
ff(i + 2) = 2: ff(i + 3) = 3: ff(i + 4) = 2: ff(i + 5) = 5: ff(i + 6) = 2: ff(i + 8) = 2: ff(i + 9) = 3
ff(i + 10) = 2: ff(i + 12) = 2: ff(i + 14) = 2: ff(i + 15) = 3: ff(i + 16) = 2: ff(i + 18) = 2
ff(i + 20) = 2: ff(i + 21) = 3: ff(i + 22) = 2: ff(i + 24) = 2: ff(i + 25) = 5
ff(i + 26) = 2: ff(i + 27) = 3: ff(i + 28) = 2: ff(i + 30) = 2
Next
ff(2) = 0: ff(3) = 0: ff(5) = 0
pattern(1) = 4: pattern(2) = 2: pattern(3) = 4: pattern(4) = 2
pattern(5) = 4: pattern(6) = 6: pattern(7) = 2: pattern(8) = 6
pcand = 7: patternI = 0
While pcand < testlimitN
If ff(pcand) = 0 Then
i = pcand * pcand
patternI2 = patternI
Do
If ff(i) = 0 Then ff(i) = pcand
patternI2 = patternI2 + 1
If patternI2 = 9 Then patternI2 = 1
i = i + pattern(patternI2) * pcand
If i > topN Then Exit Do
Loop
End If
patternI = patternI + 1
If patternI = 9 Then patternI = 1
pcand = pcand + pattern(patternI)
Wend
For i = 2 To topN
Cls
Print i, ff(i)
If ff(i) = 0 Then Sound 137, 2 Else Sound 137 + (ff(i) Mod 30) * 10, 2 - ff(i) * .001
_Limit 60
Next