function step(count: number, interation: number): number { if (count === 1) return interation if (count % 2 === 0) { // Even return step(count / 2, interation + 1) } else { return step((3 * count) + 1, interation + 1) } } export function steps(count: number): number { if (!count || count < 1 || Math.trunc(count) !== count) throw new Error('Only positive integers are allowed') return step(count, 0) }