Skip to content

Commit 4dd6b30

Browse files
committed
Handled Clang and Build
1 parent 9f527a9 commit 4dd6b30

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/main/java/com/thealgorithms/others/ShorAlgorithm.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.math.BigInteger;
44
import java.util.Random;
55

6-
// The algorithm is referred from
6+
// The algorithm is referred from
77
// https://www.geeksforgeeks.org/shors-factorization-algorithm/
88
public class ShorAlgorithm {
99
// trying to find the order of exponent given the base and the number
@@ -37,15 +37,21 @@ public BigInteger[] shorAlgorithm(BigInteger number) {
3737
}
3838

3939
int result = exponent(base, number);
40-
if (result % 2 != 0) return null;
40+
if (result % 2 != 0) {
41+
return null;
42+
}
4143

4244
BigInteger congruentResult = base.modPow(BigInteger.valueOf(result / 2), number);
43-
if (congruentResult.equals(number.subtract(BigInteger.ONE))) return null;
45+
if (congruentResult.equals(number.subtract(BigInteger.ONE))) {
46+
return null;
47+
}
4448

4549
BigInteger p = congruentResult.add(BigInteger.ONE).gcd(number);
4650
BigInteger q = congruentResult.subtract(BigInteger.ONE).gcd(number);
4751

48-
if (!p.equals(BigInteger.ONE) && !q.equals(BigInteger.ONE)) return new BigInteger[] {p, q};
52+
if (!p.equals(BigInteger.ONE) && !q.equals(BigInteger.ONE)) {
53+
return new BigInteger[] {p, q};
54+
}
4955
return null;
5056
}
5157
}

src/test/java/com/thealgorithms/others/ShorAlgorithmTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import java.math.BigInteger;
44
import org.junit.jupiter.api.Test;
5-
import static org.junit.jupiter.api.Assertions.*;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
import static org.junit.jupiter.api.Assertions.assertNotNull;
7+
import static org.junit.jupiter.api.Assertions.assertNull;
68

79
public class ShorAlgorithmTest {
810

0 commit comments

Comments
 (0)