06-13-2003, 12:55 PM
Quote:Mine got till the LONG overflow, that is up to and including 7FFFh
And just in 1,5 hour
It wasn't made in QB . However, these are the test results with my program made in QB:
1 min: 2,000,000
2 min: 4,031,482
1 h: 240,482,843
Hey Neo...I'm fiddling with C the last couple days...here's a c port of my basic primer finder...on my 1.5 GHz after 6 min, the biggest prime was 190,976,059. This looks similar to what you reported re flipping the signed 4-byte int after 1.5 hr...Mine uses unsigned, so I get to go all the way to ffffffff, instead of cutting short at 7fffffff. Cheers.
Code:
#include <iostream>
using namespace std;
int main()
{
unsigned short inc = 1;
unsigned long c;
unsigned long x;
unsigned long stop;
unsigned long count=0;
unsigned long hold=1;
unsigned short array[6540]={3};
cout << "Find primes up to what number? (4,200,000,000 max)\n";
cin >> stop;
for (x=3; x<65536;x += 2) //get small primes, put in array
{
for (c=0; (x % array[c]) && (array[c]*array[c] < x) ; c++);
if (x % array[c])
{
//cout << x << " "; //use this line to show all primes
array[inc++]=x;
}
}
for (x=65537; x<stop;x += 2) //find large primes
{
for (c=0; (x % array[c]) && (array[c]*array[c] < x) ; c++);
if (x % array[c])
{
//cout << x << " "; //use this line to show all primes
if (count++ > hold)
{
cout << x << " "; //print every 100000th prime
hold += 100000;
}
}
}
cout << "\n done\n";
return 0;
}