[NBLUG/talk] OT: First 500 prime numbers
Steve Zimmerman
stevetux at sonic.net
Thu Jun 5 16:50:04 PDT 2003
Wow! This program works like a charm. Thanks, Micxz!
-- Steve Zimmerman
On Thursday 05 June 2003 04:25 pm, Micxz wrote:
> Glad to help you get your files up;
>
> I'm not much for C programming but looky here:
>
> /*
> *
> * Dumb program that generates prime numbers.
> */
> #include <stdio.h>
> #include <stdlib.h>
>
> main(){
> int this_number, divisor, not_prime;
>
> this_number = 3;
>
> while(this_number < 10000){
> divisor = this_number / 2;
> not_prime = 0;
> while(divisor > 1){
> if(this_number % divisor == 0){
> not_prime = 1;
> divisor = 0;
> }
> else
> divisor = divisor-1;
> }
>
> if(not_prime == 0)
> printf("%d is a prime number\n", this_number);
> this_number = this_number + 1;
> }
> exit(EXIT_SUCCESS);
> }
>
> I found this here:
> http://publications.gbdirect.co.uk/c_book/chapter1/some_more_programs.html
>
> I love google;
>
> Micxz
>
> Steve Zimmerman wrote:
> > I'm trying to make a program in C that prints out a table
> > of the first 10 prime numbers, in an endeavor to eventually
> > create a program that prints out the first 500 prime numbers
> > (Knuth, v1, p. 147). So far I am without success. The file is
> > www.sonic.net/~stevetux/prime2.c. See prime1.c in the same
> > directory for my successful half try.
> >
> > Anyone want to give it a shot? I'll appreciate advice, too, but
> > what I'm really looking for is code. Thanks.
> >
> > -- Steve Zimmerman
> >
> > _______________________________________________
> > talk mailing list
> > talk at nblug.org
> > http://nblug.org/mailman/listinfo/talk
>
> _______________________________________________
> talk mailing list
> talk at nblug.org
> http://nblug.org/mailman/listinfo/talk
--
Steve Zimmerman
More information about the talk
mailing list