WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Number Conversion

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Prime Number Generator2

Keywords:   prime number generator

;Prime finder "Sieve of Erastophanes"
Decimals(1)
BoxOpen(0,"Prime Finder")
Maxprime=10000
PrimeList="1"
PrimeCount=1
list=ArrDimension(Maxprime+1)

ArrInitialize(list,1)
list[0]=0
list[1]=0


index=1
;or index=2 to MaxPrime
:loop
index=index+1
if index > MaxPrime then goto done
if list[index] == 0 then goto loop
BoxTitle(index)
BoxText(strcat("Cnt=",PrimeCount,"  %%=",(PrimeCount*100.0)/index))


Primelist=strcat(PrimeList," ",index)
PrimeCount=PrimeCount+1

xx=index
:woop
xx=xx+index
if xx > MaxPrime then goto loop
list[xx]=0
goto woop

goto loop

:done

AskItemList(strcat("Cnt=",PrimeCount,"  %%=",(PrimeCount*100.0)/index),PrimeList," ",@unsorted,@single)

Article ID:   W15218
File Created: 2002:09:05:13:50:42
Last Updated: 2002:09:05:13:50:42