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