-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumgen.java
More file actions
30 lines (28 loc) · 725 Bytes
/
numgen.java
File metadata and controls
30 lines (28 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Random;
import java.util.HashSet;
import java.util.Scanner;
import java.lang.Math;
class numgen{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Base: ");
int base = Integer.valueOf(scan.nextLine());
System.out.print("Bits:");
int bits = Integer.valueOf(scan.nextLine());
HashSet<String> LON = new HashSet<String>();
while(LON.size() < (int) Math.pow(base, bits)) {
LON.add(GenNum(bits, base));
}
System.out.println(LON);
scan.close();
}
public static String GenNum(int bits, int base) {
Random bit = new Random();
int i;
String Num = "";
for(i=0;i<bits;i++) {
Num += bit.nextInt(base) + "";
}
return Num;
}
}