Sha256: d76d66f5c74ad4ee8e79f4020417807bba963c1f86bbac810bcd48783a9b1d79
Contents?: true
Size: 536 Bytes
Versions: 2
Compression:
Stored size: 536 Bytes
Contents
using System; public static class CollatzConjecture { public static int GetSteps(int input) { if(input <= 0) { throw new ArgumentException("Only positive numbers are allowed"); } int stepCount = 0; while(input != 1) { if(input % 2 == 0) { input /= 2; } else { input = (input * 3) + 1; } stepCount++; } return stepCount; } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
trackler-2.2.1.12 | tracks/csharp/exercises/collatz-conjecture/Example.cs |
trackler-2.2.1.11 | tracks/csharp/exercises/collatz-conjecture/Example.cs |