# Thread: i want generate random numbor b, but iam getting error

1. Member
Join Date
Mar 2011
Posts
7
Rep Power
0

## i want generate random numbor b, but iam getting error

Java Code:
```package pollardp1;
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.*;
import java.io.*;
/**
*
* @author ajay
*/
public class Pollardp1 {
private final static BigInteger ZERO = new BigInteger("0");
private final static BigInteger ONE  = new BigInteger("1");
private final static BigInteger TWO = new BigInteger("2");
//private final static SecureRandom random = new SecureRandom();

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

System.out.println("Enter a number to be factor");
Scanner input=new Scanner(System.in);
BigInteger n=input.nextBigInteger();
Random rand = new Random();

BigInteger b=lnr(BigInteger.valueOf(rand.nextInt()),n);
//BigInteger b  =
BigInteger r2;
int i=2;
BigInteger r=b.mod(n);
BigInteger gcd=r.subtract(ONE).gcd(n);
while(true){
while(gcd.equals(ONE))
{

for(int j=1;j<i;j++)
{
r = r.multiply(r).mod(n);
gcd=(r.subtract(ONE)).gcd(n);
}
i++;
}
if(gcd.equals(n))
{
System.out.println(ONE + "," + gcd);
break;
}
else

{
System.out.println(gcd + "," + n.divide(gcd));
break;
}
}
}}```

Enter a number to be factor
632887
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code
at pollardp1.Pollardp1.main(Pollardp1.java:34)
Java Result: 1
BUILD SUCCESSFUL (total time: 14 seconds)
Last edited by Eranga; 03-11-2011 at 09:54 AM. Reason: code tags added

2. Oh yes. What you are trying to do with this?

Java Code:
`BigInteger b=lnr(BigInteger.valueOf(rand.nextInt()),n);`

3. Member
Join Date
Mar 2011
Posts
7
Rep Power
0

## i want generate random numbor b, but iam getting error

My intension is to generate b is random big integer having number of digits as in n..

4. Now please check what you have on,

Pollardp1.java:34
hope you know the meaning of above line of quoted text.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•