Rev 14 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 14 | Rev 32 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | package de.viathinksoft.immortable.gen2; |
1 | package de.viathinksoft.immortal.gen2; |
2 | 2 | ||
3 | import java.math.BigInteger; |
3 | import java.math.BigInteger; |
4 | 4 | ||
5 | import de.viathinksoft.immortable.gen2.math.CoPrimeExpectedException; |
5 | import de.viathinksoft.immortal.gen2.math.CoPrimeExpectedException; |
6 | import de.viathinksoft.immortable.gen2.math.MathUtils; |
6 | import de.viathinksoft.immortal.gen2.math.MathUtils; |
7 | import de.viathinksoft.immortable.gen2.math.MathUtils2; |
7 | import de.viathinksoft.immortal.gen2.math.MathUtils2; |
8 | 8 | ||
9 | /** |
9 | /** |
10 | * Immortable Number Generator (ING) |
10 | * Immortable Number Generator (ING) |
11 | * |
11 | * |
12 | * @author Daniel Marschall |
12 | * @author Daniel Marschall |
13 | */ |
13 | */ |
14 | 14 | ||
15 | public class Immortable { |
15 | public class Immortal { |
16 | 16 | ||
17 | /** |
17 | /** |
18 | * Calculates M5 or M6 |
18 | * Calculates M5 or M6 |
19 | * |
19 | * |
20 | * @param base |
20 | * @param base |
21 | * @param u |
21 | * @param u |
22 | * @return |
22 | * @return |
23 | */ |
23 | */ |
24 | public static BigInteger M(ImmortableBase base, BigInteger u) { |
24 | public static BigInteger M(ImmortalBase base, BigInteger u) { |
25 | BigInteger p, q; |
25 | BigInteger p, q; |
26 | 26 | ||
27 | if (base == ImmortableBase.M5) { |
27 | if (base == ImmortalBase.M5) { |
28 | p = BigInteger.ONE; |
28 | p = BigInteger.ONE; |
29 | q = BigInteger.ZERO; |
29 | q = BigInteger.ZERO; |
30 | } else if (base == ImmortableBase.M6) { |
30 | } else if (base == ImmortalBase.M6) { |
31 | p = BigInteger.ZERO; |
31 | p = BigInteger.ZERO; |
32 | q = BigInteger.ONE; |
32 | q = BigInteger.ONE; |
33 | } else { |
33 | } else { |
34 | p = null; |
34 | p = null; |
35 | q = null; |
35 | q = null; |
Line 60... | Line 60... | ||
60 | * @param u |
60 | * @param u |
61 | * Length of number |
61 | * Length of number |
62 | * @return |
62 | * @return |
63 | */ |
63 | */ |
64 | public static BigInteger M5(BigInteger u) { |
64 | public static BigInteger M5(BigInteger u) { |
65 | return M(ImmortableBase.M5, u); |
65 | return M(ImmortalBase.M5, u); |
66 | } |
66 | } |
67 | 67 | ||
68 | /** |
68 | /** |
69 | * Gets M6(u) |
69 | * Gets M6(u) |
70 | * |
70 | * |
71 | * @param u |
71 | * @param u |
72 | * Length of number |
72 | * Length of number |
73 | * @return |
73 | * @return |
74 | */ |
74 | */ |
75 | public static BigInteger M6(BigInteger u) { |
75 | public static BigInteger M6(BigInteger u) { |
76 | return M(ImmortableBase.M6, u); |
76 | return M(ImmortalBase.M6, u); |
77 | } |
77 | } |
78 | 78 | ||
79 | /** |
79 | /** |
80 | * Toggles between M5 and M6 base. |
80 | * Toggles between M5 and M6 base. |
81 | * |
81 | * |
Line 132... | Line 132... | ||
132 | } |
132 | } |
133 | } |
133 | } |
134 | return "0"+num; |
134 | return "0"+num; |
135 | } |
135 | } |
136 | 136 | ||
137 | private Immortable() { |
137 | private Immortal() { |
138 | } |
138 | } |
139 | 139 | ||
140 | } |
140 | } |