Loading ...
Sorry, an error occurred while loading the content.

Re: [PrimeNumbers] a basic program for prime numbers

Expand Messages
  • Bob Gilson
    Burcin Aydogdu wrote: Hi all, Below is a gwbasic program that gives prime numbers infinitely. It is of course limited with the
    Message 1 of 2 , Feb 8, 2006
      Burcin Aydogdu <baydogdu2004@...> wrote: Hi all,

      Below is a gwbasic program that gives prime numbers infinitely. It is of course limited with the capacity of the computer and the programming language's infrastructure.

      This program uses an algorithm generating prime numbers as a series, without examining any of them by dividing into any previous primes.

      It is not, however, proved in terms of mathematics. We could just test first 1000 primes listed and some random numbers smaller than 500.000, which all came out as prime numbers.

      The program can count primes up to 200.000 because there are certain numbers in the series that must be skipped, and the greater the primes become, the more numbers the computer has to store in memory. Those numbers stored are only measures to calculate the numbers to be skipped in the series, so that all the outcoming numbers will be prime.

      It gives all the primes, without missing any, and never gives any number that is not prime, as far as we tested. But as I said, it is a matter of mathematical knowledge to proof (or disproof) it, and it is a matter of memory and cpu power to obtain greater primes.

      I will be thankful if you comment on the program.

      1 dim aday(9000):dim adarti(1200):dim atta(800)
      10 var=1:gel=1:winner=1:aday(1)=6:varti=1:garti=1:winnerti=1:adarti(1)=8
      11 varta=1:gelta=1:winta=1:atta(1)=9
      15 tellioglu(1)=4:tellioglu(2)=20:seferoglu(1)=8:seferoglu(2)=28
      17 input "kaca kadarki asallar yazilsin";j
      20 a=a+1
      40 asal=(6*a)-1:bir=-1
      45 if a=aday(winner) then goto 50
      47 goto 500
      50 if var=gel then var=var+1:aday(var)=(var*7)-1
      52 aday(gel)=aday(gel)+(gel*6)-1
      54 winner=var
      55 for ad=2 to var
      70 if aday(var-ad+1)=aday(winner) then aday(var-ad+1)=aday(var-ad+1)+((var-ad+1)
      73 if aday(var-ad+1)<aday(winner) then winner=var-ad+1
      80 next ad
      90 gel=winner
      200 asal=(6*a)+1:bir=1
      210 if a=adarti(winnerti) then goto 215
      212 goto 243
      215 if garti=varti then varti=varti+1:adarti(varti)=(varti*7)+1
      218 adarti(garti)=adarti(garti)+(garti*6)+1
      220 for ad=1 to varti
      230 if adarti(varti+1-ad)<adarti(winnerti) then winnerti=varti+1-ad
      235 next ad
      237 if adarti(garti)-(garti*6)-1=>adarti(winnerti) then adarti(winnerti)=adarti(
      winnerti)+(winnerti*6)+1:goto 220
      242 garti=winnerti:pasgec=1
      243 if a=atta(winta) then pasgec=1:goto 245
      244 goto 260
      245 if varta=gelta then varta=varta+1:atta(varta)=(varta*5)-1+((varta*6)-1)
      246 atta(gelta)=atta(gelta)+(gelta*6)-1
      248 for ad=1 to varta
      254 if atta(varta-ad+1)<atta(winta) then winta=varta-ad+1
      256 next ad
      257 if atta(gelta)-(gelta*6)+1=>atta(winta) then atta(winta)=atta(winta)+(winta*
      6)-1:goto 248
      258 gelta=winta:pasgec=1
      260 if a=tellioglu(1) then goto 280
      261 if a=seferoglu(1) then goto 290
      270 goto 300
      280 tellioglu(3)=tellioglu(2)+(tellioglu(2)-tellioglu(1))+12
      281 tellioglu(1)=tellioglu(2)
      283 tellioglu(2)=tellioglu(3)
      284 pasgec=1
      285 goto 261
      290 seferoglu(3)=seferoglu(2)+(seferoglu(2)-seferoglu(1))+12
      291 seferoglu(1)=seferoglu(2)
      293 seferoglu(2)=seferoglu(3)
      294 pasgec=1
      300 if pasgec=1 then pasgec=0:goto 20
      500 rem
      700 if asal>j then end
      710 print asal;
      730 if bir=1 then goto 20
      740 goto 200

      If anyone interested, I can also try to explain the function to generate these series.


      Burcin Aydogdu

      >There are far shorter algorithms



      Yahoo! Mail - Helps protect you from nasty viruses.

      [Non-text portions of this message have been removed]

      Unsubscribe by an email to: primenumbers-unsubscribe@yahoogroups.com
      The Prime Pages : http://www.primepages.org/

      Mathematics education Mathematics and computer science Number theory


      Visit your group "primenumbers" on the web.

      To unsubscribe from this group, send an email to:

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.