A beautifull evening,
here comes the first benchmark for the quadratic prime sieve written in C
I hope that i did not make a bug.
Greetings from the primes
Bernhard
//===================================================================
//
// Prime algorithm
//
// Bernhard Helmes Aachen, 7.6.2007
// www.devalco.de
// [EMAIL PROTECTED]
//
// 1. Description
//
// The Program calculates all Primes below list_max and a lot of bigger
Primes in addition
//
// 2. Results
//
// List_max Primes Ram Time
// 10.000.000 14.575.399 87 MB 5 sec
// 100.000.000 144.809.487 722 MB 3 min
#include <stdio.h>
#include <math.h>
#define List_max 100000000
unsigned long int list [List_max];
void sieving (unsigned long int place, unsigned long int p)
{
unsigned long int i, o, res, s;
long int j;
while (place<List_max)
{
res=list [place];
res/=p;
while ((res % p)==0)
{
res/=p;
}
list [place]=res;
place+=p;
}
}
int main (void)
{
unsigned long int x, p, res, place, place_2, z=0;
// 1. Polynom
for (x=1; x<List_max; x++)
{
list [x]=2*x*x+1;
}
for (x=1; x<List_max; x++)
{
p=list[x];
if (p>1)
{
z++;
sieving (x+p, p);
sieving (p-x, p);
}
}
printf ("%i Primzahlen von %i\n", z, List_max);
// 2. Polynom
for (x=1; x<List_max; x++)
{
list [x]=2*x*x+1;
}
for (x=1; x<List_max; x++)
{
p=list[x];
if (p>1)
{
if ((p % 8)==3)
{
z++;
}
sieving (x+p, p);
sieving (p-x, p);
}
}
printf ("%i Primzahlen von %i\n", z, List_max);
// 3. Polynom
for (x=1; x<List_max; x++)
{
list [x]=2*x*x-1;
}
for (x=1; x<List_max; x++)
{
p=list[x];
if (p>1)
{
if ((p % 8)==7)
{
z++;
}
sieving (x+p, p);
sieving (p-x, p);
}
}
printf ("%i Primzahlen von %i\n", z, List_max);
}
--
www.devalco.de
www.beablue.de
Tel.: 0241 / 99 77 55 22 in Germany (0049)
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
_______________________________________________
Prime mailing list
[email protected]
http://hogranch.com/mailman/listinfo/prime