Sha256: df196d054aef8e07168a11655c5a162f430f4811d93840b64337d4ea50166521

Contents?: true

Size: 647 Bytes

Versions: 52

Compression:

Stored size: 647 Bytes

Contents

public class SumOfMultiples {
    private final int sum;

    public SumOfMultiples(int number, int[] set) {
        sum = calculateSum(number, set);
    }

    public int getSum() {
        return sum;
    }

    private int calculateSum(int number, int[] set) {

        int sum = 0;
        int count = 0;

        for (int i = 1; i < number; i++) {

            for (int j = 0; j < set.length; j++) {
                if (i % set[j] == 0) {
                    count++;
                }
            }

            if (count > 0) {
                sum = sum + i;
                count = 0;
            }
        }

        return sum;
    }

}

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
trackler-2.2.1.3 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.1.2 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.1.1 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.1.0 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.0.6 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.0.5 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.0.4 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.0.3 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.0.2 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.0.1 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.2.0.0 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.1.0.55 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.1.0.54 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.1.0.53 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.1.0.52 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.1.0.51 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.1.0.50 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.1.0.49 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.1.0.48 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java
trackler-2.1.0.47 tracks/java/exercises/sum-of-multiples/src/example/java/SumOfMultiples.java