Yes,i think i would have go with GMP.............
please suggest me other solution of my problem ....
This is a discussion on whether number is prime or not within the C Programming forums, part of the General Programming Boards category; Yes,i think i would have go with GMP............. please suggest me other solution of my problem .......
Yes,i think i would have go with GMP.............
please suggest me other solution of my problem ....
If you are going to use GMP, I recommend you use C++. The C interface to GMP is... irritating. With the C++ interface, they have overladed operators and other niceties impossible in C. I also forgot to mention that iMalc's library is in C++, with no C interface, AFAIK.
Thn x "CommonTater".......
On linux system it gives warning message while on windows system it gives error message when i was using GCC but with VC++ compiler it's all fine .
Thanx evry1 :-)
You could try to type your constant...
Code:unsigned long long x = 600851475143LL;
I'm surprised that after this many posts nobody outright knew that you simply cannot enter a constant larger than 2^32-1 without specifying a type suffix.
In this case I would use ULL though since you're assigning to an Unsigned Long Long.
If you want to do primality tests for numbers between 2^32 and 2^64, try using the deterministic version of the Miller Rabin test with the first 13 primes.
Last edited by iMalc; 01-26-2011 at 10:51 PM.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
So I read somewhere that the "absolute" theoretical limit is 2*ln(N)^2; for a 64-bit number, that would equate to trying bases below 3935. But then the maximum is apparently much lower than that (according to Pomerance, Selfridge, et al). I wonder why there is such a huge gap between the two?
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
I've been wondering that for a little while myself.
I think it must be that the theory was enough to prove that 2ln(n) was sufficient, but in practice less is fine, but no even lower bound has been proven yet.
I'm busy trying to implement the BPSW test myself. Just have the actual Lucas pseudoprime test left to get working.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }