Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Java
for(int i=0;i<=f;i++)
	
{
    BigInteger ib=BigInteger.valueOf((long)i);
    //BigInteger r=  g1.Power(i);
    //System.out.println("g^ib =" +r);
    BigInteger s= g1.modPow(ib,p1);
    //System.out.println("r:" +r);

    //System.out.println("a" +a1);
    //System.out.println("p" +p1);
    //System.out.println("s:" +s);
    //System.out.println("a1:" +a1);
    //BigInteger a1 = BigInteger.valueOf((long)a);

    if(s.equals(a1))
    {
        System.out.println("The value of m is : \t" +i);
    }
    break;
}
//else
// System.out.print("the value did not match \n");

}
Posted
Updated 13-Dec-11 3:44am
v2
Comments
Sergey Alexandrovich Kryukov 13-Dec-11 10:25am    
Seriously? Does the compiler tell you anything? :-)
--SA

Because you've commented out the line that defines a1...
 
Share this answer
 
v2
Comments
Nagy Vilmos 13-Dec-11 9:49am    
Cruel Mr Simmons, accurate but cruel. :)
#realJSOP 13-Dec-11 10:30am    
Why is it cruel? "Cruel" would be telling the guy he's a dipshit...
Nagy Vilmos 13-Dec-11 10:52am    
:))
LanFanNinja 13-Dec-11 9:57am    
+5 Judging by the code posted I would have to agree.
Sergey Alexandrovich Kryukov 13-Dec-11 10:25am    
Ha-ha, that sneaked in while OP wasn't watching. My 5.
--SA
Is a1 a BigInteger? If so, the comparison will work; see the Java Doc[^].
 
Share this answer
 
its not about the comment line . i have already declared a1 in the previous code and i have tried using it in the for loop but it is of no use.
the condition is not checked for big integers.
if i give small input numbers its executing correctly.
 
Share this answer
 
Comments
Richard MacCutchan 13-Dec-11 11:32am    
Edit your question, remove all the superfluous comments and post the exact code that you have successfully compiled. Show the values of the data you are using and the actual results you receive.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900