Sha256: ccd849ee06464c471954bfe95afaa2b26c5b92821e6b64812d5e7714cb5ea08b

Contents?: true

Size: 402 Bytes

Versions: 216

Compression:

Stored size: 402 Bytes

Contents

class CollatzCalculator {

    int computeStepCount(final int start) {
        if (start <= 0) throw new IllegalArgumentException("Only natural numbers are allowed");

        if (start == 1) return 0;

        final int next;

        if (start % 2 == 0) {
            next = start / 2;
        } else {
            next = 3 * start + 1;
        }

        return 1 + computeStepCount(next);
    }

}

Version data entries

216 entries across 216 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.179 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.178 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.177 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.176 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.175 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.174 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.173 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.172 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.171 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.170 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.169 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.167 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.166 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.165 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.164 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.163 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.162 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.161 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java
trackler-2.2.1.160 tracks/java/exercises/collatz-conjecture/.meta/src/reference/java/CollatzCalculator.java