Sha256: c3c21c126f0072d8dfb049ded69d3505ec15a883c10fbad21d16234b092254a1

Contents?: true

Size: 223 Bytes

Versions: 169

Compression:

Stored size: 223 Bytes

Contents

function collatz(n::Integer)
    n <= 0 && throw(DomainError())
    iseven(n) ? div(n, 2) : 3n + 1
end

function collatz_steps(n::Integer)
    i = 0
    while n != 1
        n = collatz(n)
        i += 1
    end

    i
end

Version data entries

169 entries across 169 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.179 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.178 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.177 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.176 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.175 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.174 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.173 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.172 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.171 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.170 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.169 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.167 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.166 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.165 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.164 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.163 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.162 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.161 tracks/julia/exercises/collatz-conjecture/example.jl
trackler-2.2.1.160 tracks/julia/exercises/collatz-conjecture/example.jl