Audio presentation of numbers as prime (=0) or first factor
#1
Code:
' 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 = 500000 TO topN
   CLS
   PRINT i, ff(i)
   IF ff(i) = 0 THEN SOUND 137, 2 ELSE SOUND 137 + ff(i) * 10, 2 - ff(i) * .001
   _LIMIT 5
NEXT


Append: Sped up and modulated:
Code:
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
B += x
Reply
#2
It's pretty cool... but I don't think it will top the music charts...

J
May your journey be free of incident.

Live long and prosper.
Reply
#3
(09-20-2017, 05:58 PM)johnno56 Wrote: It's pretty cool... but I don't think it will top the music charts...

J
Wink maybe not on Earth...
Hey Johnno are you working on anything?
B += x
Reply
#4
I'm trying to re-create the old "1945" game. But, I hesitate in trying using QB64, as I seem to have problems displaying loaded sprites. I can create a sprite, using the primitive graphics commands etc, then display them without a problem. But, using sprite (bmp, png) files, I always get an 'invalid handle'. Even though I use the 'exact' same format that is in the 'help', I still get an error. I am of the opinion that it not a filename issue or a file format issue but an internal issue with _putimage() and Linux and or 64 bit... On rare occasions I will get a 'c++ compilation error' (even when the file is empty... lol) but, as I said, that's rare...

The game itself is quite straight forward and simple in its appearance. I originally had 'the listing' written for Naalaa but had lost it after several hard drive failures... lol  But, other than that, no. I'm not working on much at all. I 'troll' the Forums several times a day, just to keep in touch, and to pick up ideas. It gets a little disheartening when there is no apparent activity on some sites... It makes it a bit hard to learn when there is no one around to answer questions... *sigh*  But, I digress, why do you ask? Have you something in mind? (gleefully rubbing hands together in expectation...)

Time for coffee... the grey cells need a kick start... lol

J
May your journey be free of incident.

Live long and prosper.
Reply
#5
Does the filename have a space in it?

Oops this is wrong post for this reply and I am not allowed to delete post for some silly reason.

When you try to use putImage, does the file have spaces in the name? I have heard that Linux is picky that way.
B += x
Reply
#6
Not 100% sure about the spaces. But, if there are any, I usually encase the filename in quotes. eg: "the dog.png". But no. As a rule I avoid using spaces. Sometimes I use an underscore instead.

I've posted the problem with Walter to see if he knows anything... It could be just me... lol

J
May your journey be free of incident.

Live long and prosper.
Reply