How to find prime of Big integer number?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karimkhan
    New Member
    • Jan 2011
    • 54

    How to find prime of Big integer number?

    I want to find all the prime number less then some given big integer number.

    like

    BigInteger n=new BigInteger(jTex tField1.getText ());
    then all prime number less then n.

    While I tried it was giving error the increment and comparison operator can not be applied to BigInt..

    Code:
    for (i=1;i<n; n.add(BigInteger.ONE)) // Error : -- and >= can not be applied to java.math.BigInteger
    {
    
    int ctr=0;
    for(x =i; x>=1; x--) // Error : -- and >= can not be applied to java.math.BigInteger
    {
    if(i%x==0) //Error : % can not be applied to java.math.BigInteger
    {
    ctr = ctr + 1;
    }
    }
    if (ctr ==2)
    {
    System.out.print(" " + i);
    }
    
    }
    Any solution to this?
    Last edited by Rabbit; Feb 4 '13, 05:21 AM. Reason: Please use code tags when posting code.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Out of pure interest, i google for the answer ;)
    it seems to be here: http://stackoverflow.com/questions/1...use-biginteger

    There is a long way to go before you hit the jackpot:

    Comment

    Working...