Sha256: 059f862f6b5bd2694e1f74c2457f831ac5c6f33e29ace3f3cf2a8d3f550be2f8

Contents?: true

Size: 259 Bytes

Versions: 94

Compression:

Stored size: 259 Bytes

Contents

def collatz_steps(n):
    if n <= 0:
        return

    step_count = 0
    while n > 1:
        if is_odd(n):
            n = n * 3 + 1
        else:
            n = n / 2
        step_count += 1

    return step_count


def is_odd(n):
    return n % 2 == 1

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
trackler-2.2.1.47 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.46 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.45 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.44 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.43 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.42 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.41 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.40 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.39 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.38 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.37 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.36 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.35 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.34 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.33 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.32 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.31 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.30 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.29 tracks/python/exercises/collatz-conjecture/example.py
trackler-2.2.1.28 tracks/python/exercises/collatz-conjecture/example.py