Benchmark: 3n + 1 Problem
The Collatz Conjecture, also known as 3n + 1, is a mathematical problem that has puzzled mathematicians for years. The conjecture states that if you take any positive integer n, and if n is even, divide it by 2, and if n is odd, multiply it by 3 and add 1, and repeat this process, you will eventually reach the number 1. This benchmark tests the performance of the 3n + 1 problem on the number “837,799” which takes 524 steps to reach 1.
number
math
algorithm
All-Time Rankings
Rank | Language | Average Time | Best Time | Worst Time |
---|---|---|---|---|
1 | C (Clang) | 2.772µs | 2.300µs | 3.100µs |
2 | C++ (Clang++) | 2.876µs | 2.600µs | 3.400µs |
3 | C (GCC) | 3.140µs | 2.800µs | 3.400µs |
4 | C++ (G++) | 3.188µs | 2.800µs | 3.500µs |
5 | Rust | 3.688µs | 3.300µs | 4.000µs |
6 | Go | 29.152µs | 0.000µs | 728.800µs |
7 | Kotlin (Native) | 32.784µs | 18.000µs | 351.900µs |
8 | Java | 72.420µs | 42.700µs | 275.100µs |
9 | PHP | 88.152µs | 68.800µs | 429.900µs |
10 | JavaScript (Node) | 94.708µs | 83.600µs | 120.600µs |
11 | Python | 167.488µs | 145.800µs | 218.100µs |
12 | Ruby | 1,442.400µs | 61.200µs | 33,899.900µs |
13 | JavaScript (Deno) | 4,837.112µs | 214.900µs | 83,074.200µs |
14 | Kotlin (JVM) | 5,144.128µs | 621.900µs | 111,003.100µs |
15 | JavaScript (Bun) | 257,242.756µs | 68,119.600µs | 1,426,168.500µs |