Skip to content

Commit 3e5e1ab

Browse files
modified
1 parent 2156b67 commit 3e5e1ab

2 files changed

Lines changed: 11 additions & 45 deletions

File tree

src/main/java/com/thealgorithms/maths/SquareFreeInteger.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.thealgorithms.maths;
1+
package com.thealgorithms.maths.Prime;
22

33
/**
4-
* A square-free integer is an integer divisible by no perfect square other than 1
4+
* A square-free integer is an integer divisible by no perfect square other than 1.
55
* In other words, its prime factorization has no repeated factors.
66
* Examples: 1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15...
77
* Non-examples: 4, 8, 9, 12, 16, 18 (all divisible by 4 or 9)
@@ -14,18 +14,18 @@ private SquareFreeInteger() {
1414
}
1515

1616
/**
17-
* Checks if a given number is square-free.
17+
* Checks if a given number is a square-free integer.
1818
*
19-
* @param num the number to check (this must be positive)
20-
* @return true if num is square-free, false otherwise
21-
* @throws IllegalArgumentException if num is not positive
19+
* @param number the number to check (must be greater than zero)
20+
* @return true if number is square-free, false otherwise
21+
* @throws IllegalArgumentException if number is not greater than zero
2222
*/
23-
public static boolean isSquareFree(int num) {
24-
if (num <= 0) {
25-
throw new IllegalArgumentException("Input must be a positive integer.");
23+
public static boolean isSquareFreeInteger(int number) {
24+
if (number <= 0) {
25+
throw new IllegalArgumentException("Number must be greater than zero.");
2626
}
27-
for (int i = 2; (long) i * i <= num; i++) {
28-
if (num % (i * i) == 0) {
27+
for (int i = 2; (long) i * i <= number; i++) {
28+
if (number % (i * i) == 0) {
2929
return false;
3030
}
3131
}

src/test/java/com/thealgorithms/maths/SquareFreeIntegerNew.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)