package de.bplaced.mtgxyz.primes;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.util.HashMap;
public class Prim {
static BigInteger plusone(BigInteger val)
{
byte[] test=new byte[128];
test[0]=1;
return val.add(new BigInteger(test));
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
File primefile=new File("primes.txt");
if(primefile.exists()) primefile.delete();
primefile.createNewFile();
BufferedWriter bw = new BufferedWriter(new FileWriter(primefile));
byte[] max=new byte[128];
byte[] min=max;
min[0]=1;
for(int i=0;i<128;i++)
max[i]=-1;
BigInteger maxval=new BigInteger(max);
for(BigInteger i=new BigInteger(min);(i.compareTo(maxval))==-1;i=plusone(i)) {
if(i.isProbablePrime(Integer.MAX_VALUE)) bw.write(i.toString()+"\r\n"); bw.flush(); System.out.println(i.toString());
}
bw.close();
}
}