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 (GCC) | 2.983µs | 2.810µs | 3.200µs |
2 | Go | 3.000µs | 3.000µs | 3.000µs |
3 | C++ (G++) | 3.040µs | 2.000µs | 4.000µs |
4 | C (Clang) | 3.379µs | 3.224µs | 3.660µs |
5 | C++ (Clang++) | 3.483µs | 3.296µs | 3.751µs |
6 | Rust | 3.720µs | 3.000µs | 5.000µs |
7 | Kotlin (Native) | 23.844µs | 15.860µs | 202.148µs |
8 | Ruby | 67.960µs | 57.000µs | 223.000µs |
9 | PHP | 97.195µs | 90.575µs | 146.221µs |
10 | Java | 102.552µs | 58.600µs | 515.571µs |
11 | Python | 178.000µs | 139.000µs | 891.000µs |
12 | JavaScript (Node) | 257.816µs | 118.883µs | 3,219.696µs |
13 | JavaScript (Deno) | 768.200µs | 241.001µs | 11,265.647µs |
14 | Kotlin (JVM) | 890.210µs | 475.954µs | 2,971.259µs |
15 | JavaScript (Bun) | 26,907.190µs | 251.733µs | 648,843.870µs |