← Math & statistics

Pi Digits Generator

Compute pi to high precision in your browser and return the requested number of digits after the decimal point. Use digits mode for a specific length, or the time challenge to see how many digits can be completed within the selected time.

If you want to search inside the generated prefix, open Pi Digit Lab. If you want the learning-first version, return to Pi Approximation Explorer.

Other languages 日本語 | English | 简体中文 | 繁體中文 | 繁體中文(香港) | Español | Português (Brasil) | Français | Italiano
3 quick steps
  1. Choose digits mode for a fixed output length, or choose time challenge for a bounded run.
  2. Run a small preset first so you can confirm the display mode, copy flow, and TXT export.
  3. Open Pi Digit Lab when you want to search for one sequence, jump to an index, or copy only one selected span.

Classroom presets: confirm the flow with a short output first, then choose a worksheet-sized run or a short time challenge.

Mode

This page counts digits after the decimal point. The output always starts with 3..

Auto shows the full block up to 5,000 digits and switches to a head/tail preview above that point.

Digits after the decimal point

Generated digits
Elapsed ms
Chudnovsky terms
Status
Display

Output

No output yet.

How it works

The calculator uses the Chudnovsky series 1/π = 12 Σ(k=0…∞) (-1)^k (6k)! (13591409 + 545140134k) / ((3k)! (k!)^3 640320^(3k+3/2)). It evaluates the series with recursive binary splitting, JavaScript BigInt integer arithmetic, and an integer square root. It calculates 18 guard digits beyond the request and then truncates—rather than rounds—to the requested prefix. It does not read the answer from a stored table of pi digits.

The same calculation core normally runs in a Web Worker to keep the page responsive; if workers are unavailable, it runs on the main thread. The time challenge accepts only checkpoints that finish completely by the deadline.

Worksheet and export prep

FAQ

Which formula does this program use to calculate pi?

It uses the Chudnovsky series, evaluated with recursive binary splitting, BigInt integer arithmetic, and an integer square root. It computes 18 extra guard digits before truncating to the requested length; it does not look up digits in a stored table.

Does this page represent pi exactly?

No. Pi has infinitely many decimal digits, so no finite string represents pi itself exactly. This page performs a high-precision calculation and returns the requested decimal prefix.

What does first n digits mean here?

The input counts digits after the decimal point. If you enter 100, the result is 3. followed by 100 digits.

Why does the page switch to head and tail after 5,000 digits?

Rendering a huge text block is unnecessary for most sessions, so the page previews the beginning and the end by default while keeping the full text for copy and TXT export.

What is the time challenge mode?

The page tries checkpoints in increasing sizes and keeps the largest one whose calculation finishes completely within the selected time. A result that finishes after the deadline is not accepted.

What happens when I press stop?

In digits mode, the calculation is cancelled and no incomplete result is shown. In time challenge mode, the current calculation is cancelled and the most recent completed checkpoint remains available, if there is one.