Benchmarks

Windows 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 Go 0.000µs 0.000µs 0.000µs
2 D 1.588µs 1.400µs 1.700µs
3 C++ (Clang++) 2.836µs 2.400µs 3.000µs
4 GraalVM 3.000µs 2.800µs 3.200µs
5 C++ (G++) 3.216µs 2.800µs 3.400µs
6 C (Clang) 3.236µs 3.000µs 3.500µs
7 Rust 3.552µs 3.100µs 4.000µs
8 Zig 3.852µs 3.300µs 5.400µs
9 C (GCC) 4.440µs 3.000µs 34.500µs
10 Kotlin (Native) 57.024µs 18.600µs 698.900µs
11 Ruby 90.748µs 59.800µs 392.000µs
12 JavaScript (Node) 106.408µs 93.100µs 130.700µs
13 PHP 133.936µs 63.700µs 751.200µs
14 Python 185.640µs 149.900µs 418.500µs
15 JavaScript (Deno) 531.760µs 200.300µs 1,542.400µs
16 Kotlin (JVM) 4,529.812µs 673.800µs 88,267.900µs
17 Java 4,934.356µs 46.100µs 121,679.300µs
18 JavaScript (Bun) 179,983.712µs 65,212.900µs 691,058.700µs

Average Times

Median Times

Best-Case Scenario Times

Worst-Case Scenario Times