Thread: whether number is prime or not

  1. #16
    Registered User
    Join Date
    Jan 2011
    Posts
    10
    Yes,i think i would have go with GMP.............

    please suggest me other solution of my problem ....

  2. #17
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    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.

  3. #18
    Registered User
    Join Date
    Jan 2011
    Posts
    10
    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 :-)

  4. #19
    Bit Fiddler
    Join Date
    Sep 2009
    Posts
    79
    You could try to type your constant...
    Code:
    unsigned long long x = 600851475143LL;

  5. #20
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by Fader_Berg View Post
    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 11: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"

  6. #21
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by iMalc View Post
    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.
    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;
    }

  7. #22
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by Sebastiani View Post
    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?
    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"

  8. #23
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by iMalc View Post
    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.
    Hmm...the BPSW sounds even more interesting still. No counterexamples to date? Wow!
    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;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple XOR Program
    By dolfaniss in forum C Programming
    Replies: 8
    Last Post: 05-24-2010, 01:27 PM
  2. Prime number example
    By Johnathan1707 in forum C Programming
    Replies: 2
    Last Post: 07-26-2009, 12:40 PM
  3. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  4. Prime Factor Fxn
    By alpha in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2003, 10:44 AM
  5. Replies: 3
    Last Post: 01-14-2003, 10:34 PM