Sha256: 8a3ddbd8600e8892480a9b9a78899a58ff20ea5d0e7be30cd86fa6ccba23b303
Contents?: true
Size: 457 Bytes
Versions: 78
Compression:
Stored size: 457 Bytes
Contents
#import "CollatzConjectureExample.h" @implementation CollatzConjecture + (NSInteger)stepsForNumber:(NSInteger)number { if (number <= 0) { return NSNotFound; } NSInteger current = number; NSInteger steps = 0; while (current > 1) { steps++; if (current % 2 == 0) { current /= 2; } else { current = current * 3 + 1; } } return steps; } @end
Version data entries
78 entries across 78 versions & 1 rubygems