HenrikLovold / FastCollatz

Can you make it fast?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FastCollatz

Can you make it fast?

What is Collatz' conjecture?

See Wikipedia.

What is the challenge?

Compute the length of all Collatz paths for numbers 2 to N as fast as possible. Some example lengths:

Number Path length
2 1
3 7
4 2
5 5
6 8

If you need an example program, have a look at this file.

Basic Collatz function

collatz(x):
  if x % 2 == 0:
    return x / 2
  else:
    return x*3 + 1

Rules

  • Calculate all Collatz paths for 2 to N
  • Your program's first argument must be N

For testing purposes, run $N=1*10^7$, as this is what we're benchmarking.

About

Can you make it fast?


Languages

Language:C++ 64.2%Language:Rust 18.4%Language:Python 15.7%Language:Clojure 1.8%