I need to generate two primes p1, p2 bigger than 10^25, and their product n. and a number "a" less than n.
Why I use the code below, the result of 4 number are all 0.
public static void main(String args[]) {
long min = (long) Math.pow(10, 25);
long max = Long.MAX_VALUE;
long p1 = (long)((Math.random()+1)*(max-min));
long p2 = (long)((Math.random()+1)*(max-min));
long n = p1 * p2 ;
long a = (long)((Math.random())* n) ;
System.out.println("p1= " + p1 + ", p2= " + p2 + ", n= " + n +",a= " + a);
}
Thank you.
Aucun commentaire:
Enregistrer un commentaire