🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.apple2
Article #12

v001SRC015: sieve -- Compute Primes Using Eratosthenes' Sieve

#12
From: Jonathan A. Chandross
Date: Sat, 01 Dec 1990 21:53
61 lines
1518 bytes
Submitted-by: NONE
Posting-number: Volume 1, Source:15
Archive-name: util/sieve
Architecture: ANY_2
Version-number: 1.00

No computer should be without a program to compute prime numbers.
Here's one.

Enjoy.

=primes.c
-/*
- *
- * sieve.c
- *
- * Eratosthenes Sieve Prime Number Program.
- *
- * Usage:
- *	seive 
- *
- * Contributed Anonymously.  Written: November 1983
- *
- * Version 1.00
- *
- */
-
-#define TRUE  1
-#define FALSE 0
-#define SIZE 8190 
-
-char flags[SIZE+1] ;
-
-main()
-{
-   int i, prime, k, count, iter ;
-
-   printf("10 iterations\n") ;
-
-   for( iter=1 ; iter <= 10 ; iter++ ) {
-	  count = 0 ;
-	  for( i=0 ; i <= SIZE ; i++ )
-		 flags[i] = TRUE ;
-	  for( i=0 ; i<= SIZE ; i++ ) {
-		 if( flags[i] ) {
-			prime = i + i + 3 ;
-/*			printf("\n%d", prime ) ; */
-			for( k=i+prime ; k <= SIZE ; k+=prime )
-			   flags[k] = FALSE ;
-			count++ ;
-		 }
-	  }
-   }
-
-   printf("\n%d primes.\n", count ) ;
-
-} /* end main */
-
-
+ END OF ARCHIVE
Technical Details
Message-ID: <Dec.1.16.53.21.1990.24783@yoko.rutgers.edu>
Path: arc1-ca.pugleaf.net!wuarchive!swbatl!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!usc!rutgers!aramis.rutgers.edu!paul.rutgers.edu!yoko.rutgers.edu!jac

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wuarchive!swbatl!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!usc!rutgers!aramis.rutgers.edu!paul.rutgers.edu!yoko.rutgers.edu!jac
From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
Newsgroups: comp.sources.apple2
Subject: v001SRC015:  sieve -- Compute Primes Using Eratosthenes' Sieve
Message-ID: <Dec.1.16.53.21.1990.24783@yoko.rutgers.edu>
Date: 1 Dec 90 21:53:22 GMT
Organization: Rutgers Univ., New Brunswick, N.J.
Lines: 61
Approved: jac@paul.rutgers.edu