/**********************************************************************/
/*  Jeff Balsley      Sun Jan 28 20:22:46 PST 2001                    */
/*  This code will calculate prime numbers                            */
/*  gcc -lm primes_basic.c -o primes_basic                            */
/**********************************************************************/

#include <stdio.h>

#define START 2
#define END 10000     /* Find all the primes up to this integer  */
#define TRUE 1
#define FALSE 0

int main(void)
{
    int i,j;
    int prime;
    FILE *outp;

    for (i=START; i < END; ++i){
        prime = TRUE;
        for (j=2; j < i; ++j){
            if( ( i % j ) == 0 ){
                prime = FALSE;
            }
        }
        /*  print prime number to file  */
        if (prime == TRUE){
            outp = fopen("basic_primes.dat","a");
            fprintf(outp, "%d\n", i);
            fclose(outp);
        }
    }

    /* fclose(outp); */
    return(0);
}



