Sha256: 43747af61126fcdf717883efdc271f0adaba537c7b02922b9857b733287ade66

Contents?: true

Size: 437 Bytes

Versions: 142

Compression:

Stored size: 437 Bytes

Contents

import java.util.ArrayList;
import java.util.List;

public class PrimeFactors {

    public static List<Long> getForNumber(long number) {
        List<Long> primes = new ArrayList<>();
        long divisor = 2;

        while (number > 1) {
            while (number % divisor == 0) {
                primes.add(divisor);
                number /= divisor;
            }

            divisor++;
        }

        return primes;
    }
}

Version data entries

142 entries across 142 versions & 1 rubygems

Version Path
trackler-2.0.8.42 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.41 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.40 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.39 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.38 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.37 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.36 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.35 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.34 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.33 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.32 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.31 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.30 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.29 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.28 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.27 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.26 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.24 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.23 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java
trackler-2.0.8.22 tracks/java/exercises/prime-factors/src/example/java/PrimeFactors.java