Problem statement:
write an algorithm to generate 17 digit unique number.
public class GenerateUniqueRandNums {
public static void main(String args[]) {
for (int count = 0; count < 1000000; count++) {
long unqNum = System.nanoTime();
System.out.println("unique: " + unqNum* 100);
}
}
}
Note: we must create new instance on every single iteration withing a loop, then only it could be, else single instance will get looped over the multiple times.
Output:
unique: 2750731359372300
unique: 2750731485912300
unique: 2750731491573500
unique: 2750731496781900
unique: 2750731501673200
unique: 2750731569698600
--------------------------------
--------------------------------
--------------------------------
*************************************************
public class GenerateUniqueRandNum {
public static void main(String args[]) {
long unqNum = System.nanoTime();
for (int count = 0; count < 1000000; count++) {
System.out.println("unique: " + unqNum* 100);
}
}
}
Output:
unique: 2946684697352300
unique: 2946684697352300
unique: 2946684697352300
unique: 2946684697352300
unique: 2946684697352300
unique: 2946684697352300
--------------------------------
--------------------------------
--------------------------------
write an algorithm to generate 17 digit unique number.
public class GenerateUniqueRandNums {
public static void main(String args[]) {
for (int count = 0; count < 1000000; count++) {
long unqNum = System.nanoTime();
System.out.println("unique: " + unqNum* 100);
}
}
}
Note: we must create new instance on every single iteration withing a loop, then only it could be, else single instance will get looped over the multiple times.
Output:
unique: 2750731359372300
unique: 2750731485912300
unique: 2750731491573500
unique: 2750731496781900
unique: 2750731501673200
unique: 2750731569698600
--------------------------------
--------------------------------
--------------------------------
*************************************************
public class GenerateUniqueRandNum {
public static void main(String args[]) {
long unqNum = System.nanoTime();
for (int count = 0; count < 1000000; count++) {
System.out.println("unique: " + unqNum* 100);
}
}
}
Output:
unique: 2946684697352300
unique: 2946684697352300
unique: 2946684697352300
unique: 2946684697352300
unique: 2946684697352300
unique: 2946684697352300
--------------------------------
--------------------------------
--------------------------------
No comments:
Post a Comment