Sha256: 1e9a06ae6f3374236a3b46811a02fec37a8fbe50320c4660dafae08ff3636d01
Contents?: true
Size: 540 Bytes
Versions: 166
Compression:
Stored size: 540 Bytes
Contents
using System; public static class CollatzConjecture { public static int Steps(int number) { if(number <= 0) { throw new ArgumentException("Only positive numbers are allowed"); } int stepCount = 0; while(number != 1) { if(number % 2 == 0) { number /= 2; } else { number = (number * 3) + 1; } stepCount++; } return stepCount; } }
Version data entries
166 entries across 166 versions & 1 rubygems