-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolyDiv.java
More file actions
32 lines (30 loc) · 884 Bytes
/
Copy pathpolyDiv.java
File metadata and controls
32 lines (30 loc) · 884 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
31
32
public class polyDiv {
private static void polyDiv_helper(boolean [] opted, int base, int workfor_digit, long solution)
{
if(base == workfor_digit){
System.out.println(solution);
return;
}
int digit;
for (digit = 1; digit < base; digit++){
if (opted [digit] == false)
{
long conVal = solution * 10 + digit;
if (conVal % workfor_digit == 0){
opted [digit] = true;
polyDiv_helper(opted, base, workfor_digit + 1, conVal);
opted [digit] = false;
}
}
}
}
public polyDiv()
{
boolean [] opted = new boolean[10];
polyDiv_helper(opted, 10, 1, 0);
}
public static void main(String[] args)
{
new polyDiv();
}
}