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.552µs 1.400µs 1.700µs
3 C++ (Clang++) 2.784µs 2.600µs 3.000µs
4 GraalVM 3.044µs 2.800µs 3.300µs
5 C++ (G++) 3.164µs 2.700µs 3.400µs
6 Rust 3.480µs 3.100µs 3.800µs
7 Zig 3.756µs 3.200µs 4.100µs
8 C (GCC) 4.148µs 2.700µs 28.200µs
9 C (Clang) 4.212µs 2.900µs 28.800µs
10 Kotlin (Native) 25.348µs 18.100µs 140.300µs
11 PHP 70.468µs 59.200µs 94.800µs
12 JavaScript (Node) 121.120µs 90.500µs 462.200µs
13 Python 170.424µs 139.400µs 316.900µs
14 Ruby 174.536µs 63.700µs 2,449.400µs
15 JavaScript (Deno) 476.348µs 189.300µs 2,308.100µs
16 Kotlin (JVM) 840.224µs 689.500µs 1,500.800µs
17 Java 7,277.784µs 47.300µs 76,791.000µs
18 JavaScript (Bun) 199,195.828µs 67,300.700µs 397,693.300µs

Average Times

Median Times

Best-Case Scenario Times

Worst-Case Scenario Times