math.answers.com/math-and-arithmetic/Gw_basicCode_for_prime_numbers

Preview meta tags from the math.answers.com website.

Linked Hostnames

8

Thumbnail

Search Engine Appearance

Google

https://math.answers.com/math-and-arithmetic/Gw_basicCode_for_prime_numbers

Gw basicCode for prime numbers? - Answers

10 REM I believe this program will do what you want, but bear in mind that 20 REM I don't have GWBASIC and haven't used it in years, so I'm going by 30 REM memory and human error checking alone. There may be typos and 40 REM the like. This program finds up to MAXPRIMES prime numbers and 50 REM stores them in the array PRIME. It's then dumped out on the screen. 60 REM Enjoy! 70 REM 100 DEFINT A-Z 110 MAXPRIMES=1000:NUMPRIMES=2 120 DIM PRIME(1000) 130 PRIME(0) = 2:PRIME(1) = 3 140 CURRENTNUM = 5 150 WHILE(NUMPRIMES < MAXPRIMES) 160 TESTNUMBER = CURRENTNUM 170 GOSUB 1010 180 IF ISPRIME = 1THEN 190 PRIME(NUMPRIMES) = CURRENTNUM 200 NUMPRIMES = NUMPRIMES + 1 210 END IF 220 REM -- take advantage of the fact that all primes greater than 230 REM -- three are one away from a multiple of six 240 IF (CURRENTNUM + 1) MOD 6 = 0 THEN 250 CURRENTNUM = CURRENTNUM + 2 260 ELSE 270 CURRENTNUM = CURRENTNUM + 4 280 END IF 290 WEND 300 REM ============= 992 REM 1000 REM A Subroutine to see if the number TESTNUMBER is prime 1010 N = 0 1020 ISPRIME = 1 1030 WHILE ISPRIME = 1 AND N < NUMPRIMES AND PRIME(N) * PRIME(N) <= TESTNUMBER 1040 IF TESTNUMBER MOD PRIME(N) = 0 THEN ISPPRIME = 0 1050 N = N + 1 1060 WEND 1070 RETURN



Bing

Gw basicCode for prime numbers? - Answers

https://math.answers.com/math-and-arithmetic/Gw_basicCode_for_prime_numbers

10 REM I believe this program will do what you want, but bear in mind that 20 REM I don't have GWBASIC and haven't used it in years, so I'm going by 30 REM memory and human error checking alone. There may be typos and 40 REM the like. This program finds up to MAXPRIMES prime numbers and 50 REM stores them in the array PRIME. It's then dumped out on the screen. 60 REM Enjoy! 70 REM 100 DEFINT A-Z 110 MAXPRIMES=1000:NUMPRIMES=2 120 DIM PRIME(1000) 130 PRIME(0) = 2:PRIME(1) = 3 140 CURRENTNUM = 5 150 WHILE(NUMPRIMES < MAXPRIMES) 160 TESTNUMBER = CURRENTNUM 170 GOSUB 1010 180 IF ISPRIME = 1THEN 190 PRIME(NUMPRIMES) = CURRENTNUM 200 NUMPRIMES = NUMPRIMES + 1 210 END IF 220 REM -- take advantage of the fact that all primes greater than 230 REM -- three are one away from a multiple of six 240 IF (CURRENTNUM + 1) MOD 6 = 0 THEN 250 CURRENTNUM = CURRENTNUM + 2 260 ELSE 270 CURRENTNUM = CURRENTNUM + 4 280 END IF 290 WEND 300 REM ============= 992 REM 1000 REM A Subroutine to see if the number TESTNUMBER is prime 1010 N = 0 1020 ISPRIME = 1 1030 WHILE ISPRIME = 1 AND N < NUMPRIMES AND PRIME(N) * PRIME(N) <= TESTNUMBER 1040 IF TESTNUMBER MOD PRIME(N) = 0 THEN ISPPRIME = 0 1050 N = N + 1 1060 WEND 1070 RETURN



DuckDuckGo

https://math.answers.com/math-and-arithmetic/Gw_basicCode_for_prime_numbers

Gw basicCode for prime numbers? - Answers

10 REM I believe this program will do what you want, but bear in mind that 20 REM I don't have GWBASIC and haven't used it in years, so I'm going by 30 REM memory and human error checking alone. There may be typos and 40 REM the like. This program finds up to MAXPRIMES prime numbers and 50 REM stores them in the array PRIME. It's then dumped out on the screen. 60 REM Enjoy! 70 REM 100 DEFINT A-Z 110 MAXPRIMES=1000:NUMPRIMES=2 120 DIM PRIME(1000) 130 PRIME(0) = 2:PRIME(1) = 3 140 CURRENTNUM = 5 150 WHILE(NUMPRIMES < MAXPRIMES) 160 TESTNUMBER = CURRENTNUM 170 GOSUB 1010 180 IF ISPRIME = 1THEN 190 PRIME(NUMPRIMES) = CURRENTNUM 200 NUMPRIMES = NUMPRIMES + 1 210 END IF 220 REM -- take advantage of the fact that all primes greater than 230 REM -- three are one away from a multiple of six 240 IF (CURRENTNUM + 1) MOD 6 = 0 THEN 250 CURRENTNUM = CURRENTNUM + 2 260 ELSE 270 CURRENTNUM = CURRENTNUM + 4 280 END IF 290 WEND 300 REM ============= 992 REM 1000 REM A Subroutine to see if the number TESTNUMBER is prime 1010 N = 0 1020 ISPRIME = 1 1030 WHILE ISPRIME = 1 AND N < NUMPRIMES AND PRIME(N) * PRIME(N) <= TESTNUMBER 1040 IF TESTNUMBER MOD PRIME(N) = 0 THEN ISPPRIME = 0 1050 N = N + 1 1060 WEND 1070 RETURN

  • General Meta Tags

    22
    • title
      Gw basicCode for prime numbers? - Answers
    • charset
      utf-8
    • Content-Type
      text/html; charset=utf-8
    • viewport
      minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no
    • X-UA-Compatible
      IE=edge,chrome=1
  • Open Graph Meta Tags

    7
    • og:image
      https://st.answers.com/html_test_assets/Answers_Blue.jpeg
    • og:image:width
      900
    • og:image:height
      900
    • og:site_name
      Answers
    • og:description
      10 REM I believe this program will do what you want, but bear in mind that 20 REM I don't have GWBASIC and haven't used it in years, so I'm going by 30 REM memory and human error checking alone. There may be typos and 40 REM the like. This program finds up to MAXPRIMES prime numbers and 50 REM stores them in the array PRIME. It's then dumped out on the screen. 60 REM Enjoy! 70 REM 100 DEFINT A-Z 110 MAXPRIMES=1000:NUMPRIMES=2 120 DIM PRIME(1000) 130 PRIME(0) = 2:PRIME(1) = 3 140 CURRENTNUM = 5 150 WHILE(NUMPRIMES < MAXPRIMES) 160 TESTNUMBER = CURRENTNUM 170 GOSUB 1010 180 IF ISPRIME = 1THEN 190 PRIME(NUMPRIMES) = CURRENTNUM 200 NUMPRIMES = NUMPRIMES + 1 210 END IF 220 REM -- take advantage of the fact that all primes greater than 230 REM -- three are one away from a multiple of six 240 IF (CURRENTNUM + 1) MOD 6 = 0 THEN 250 CURRENTNUM = CURRENTNUM + 2 260 ELSE 270 CURRENTNUM = CURRENTNUM + 4 280 END IF 290 WEND 300 REM ============= 992 REM 1000 REM A Subroutine to see if the number TESTNUMBER is prime 1010 N = 0 1020 ISPRIME = 1 1030 WHILE ISPRIME = 1 AND N < NUMPRIMES AND PRIME(N) * PRIME(N) <= TESTNUMBER 1040 IF TESTNUMBER MOD PRIME(N) = 0 THEN ISPPRIME = 0 1050 N = N + 1 1060 WEND 1070 RETURN
  • Twitter Meta Tags

    1
    • twitter:card
      summary_large_image
  • Link Tags

    16
    • alternate
      https://www.answers.com/feed.rss
    • apple-touch-icon
      /icons/180x180.png
    • canonical
      https://math.answers.com/math-and-arithmetic/Gw_basicCode_for_prime_numbers
    • icon
      /favicon.svg
    • icon
      /icons/16x16.png

Links

58