/*
* primetest.c: A program to primality test successive 10 digit
numbers extracted from the value of e.
* Author: V. Alex Brennen (http://cryptnet.net/people/vab/)
* Date: 2004.07.22
* Copyright: Public Domain.
*/
#include <stdio.h>
#include <gmp.h>
int main(void)
{
mpz_t e;
int answ = 0;
int i = 3;
FILE *in = NULL;
char *candidate = NULL;
mpz_init(e);
candidate = (char *)malloc(11);
if(NULL == (in = fopen("out.txt","r")))
{
fprintf(stderr,"Failed to open out file.\n");
return -1;
}
while(!feof(in))
{
if(i)
fseek(in,i,SEEK_SET);
fread(candidate,sizeof(char),10,in);
candidate[11] = '\0';
mpz_init_set_str(e,candidate,10);
answ = mpz_probab_prime_p(e,10);
if(answ != 0)
{
mpz_out_str(NULL,10,e);
printf("\n");
}
i++;
}
fclose(in);
if(candidate != NULL)
free(candidate);
return 0;
}