Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/src/main/java/algorithms/Primes.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package algorithms;
import java.util.Vector;
import java.util.ArrayList;

public class Primes {
/**
Expand Down Expand Up @@ -40,10 +40,10 @@ public static int SumPrimes(int n) {
* Finds all primes factors of a number
*
* @param n The number to find the prime factors of.
* @return An vector of all prime factors of n.
* @return An array list of all prime factors of n.
*/
public static Vector<Integer> PrimeFactors(int n) {
Vector<Integer> ret = new Vector<Integer>();
public static ArrayList<Integer> PrimeFactors(int n) {
ArrayList<Integer> ret = new ArrayList<Integer>();

for (int i = 2; i * i <= n; i++) { // Optimized loop condition
while (n % i == 0 && IsPrime(i)) { // Optimized to handle repeated factors
Expand All @@ -56,4 +56,4 @@ public static Vector<Integer> PrimeFactors(int n) {
}
return ret;
}
}
}