Great news people, I figured out a completely new algorithm to find prime numbers. This one is about 500 times faster than the old fast one, which means you should be able to compute numbers up to 2.6 million.
(It crashes at numbers greater than 2.6 million, no idea why. If you change the double float variables to float it can do numbers up to 30 million, but it (may) round it. (like turning 29999999 into 30000000))
Begin:
sync on
sync rate 60
set text font "Comic Sans MS"
set text size 14
local MaxNum as double integer
local Num as double integer
cls
sync : input "ENTER NUMBER: ",Num : sync
cls
MaxNum=2600000
if Num<=2 or Num>MaxNum then Num=1+rnd(MaxNum-1)
set cursor 0,0
Print "NUMBER: ",str$(Num)
print " "
IsPrime(Num)
while returnkey()=1
endwhile
wait key
while scancode()>0
endwhile
while returnkey()=0
cls
set cursor 10,10
print "PRESS ESCAPE TO QUIT OR ENTER TO CONTINUE."
if escapekey() then end
sync
endwhile
while returnkey()=1
endwhile
Goto Begin
end
function IsPrime(N as double float)
local a as double float
NumFac=2
sync : print "FACTOR PAIRS:" : sync
sync : print str$(1)+" x "+str$(n)+" ; "+str$(1) : sync
PRIME=1
LIMIT = N/2
a = 2
repeat
if int(N/a) = N/a then PRIME=0 : print str$(a)+" x "+str$(int(N/a))+" ; "+str$(a) : NumFac=NumFac+1
inc a, 1
until a > LIMIT
sync : print str$(n)+" x "+str$(1)+" ; "+str$(n) : sync
if PRIME=1 then Msg$="THE NUMBER IS PRIME. THERE ARE NO OTHER FACTORS"
sync : print MSG$ : sync
sync : print " " : sync
sync : print "# OF FACTORS FOR "+str$(N)+": ",NumFac
sync : print " " : print "=======DONE=======" : sync
endfunction PRIME
(If anyone cares to know how it works, it just runs 1 loop from 2 to N/2 and if N divides evenly into the index (a), a and N/a are added as factors.)
What's really weird is that DBP refuses to run a for loop properly when the index is a float. (That's why I have a repeat until loop.)
Do not meddle in the affairs of dragons...for you are crunchy and good with ketchup.