Collatz conjecture calculator
Start at 7 and the 3n+1 rule takes 16 steps to reach 1, climbing as high as 52 on the way. Enter any positive whole number to see its full path, step count and peak. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- N
- 7
- Peak
- 52
- Length
- 17
The Collatz conjecture calculator builds the famous three-n-plus-one hailstone sequence from a positive starting integer n down to one. At every step the rule is fixed: if the current value is even, divide by two; if it is odd, multiply by three and add one. Supply n and the tool returns the full sequence, the number of steps required to reach one, the peak value attained along the way, and the sequence length. Classic classroom examples include seven (sixteen steps, peak fifty-two) and twenty-seven (one hundred eleven steps, peak nine thousand two hundred thirty-two). The engine uses deterministic integer arithmetic with no floating-point shortcuts, so the orbit for a given n is identical on every run. It never calls the network, never samples randomness, and never depends on the clock.
What the 3n+1 rule does and what you see
The Collatz map, also called the 3n+1 problem or the hailstone process, is one of the best-known open questions in elementary number theory: does every positive integer eventually reach one under repeated application of the even and odd rules above? The conjecture, stated by Lothar Collatz in the mid-twentieth century, asserts that the answer is yes, and it has been verified by computer for staggering ranges of n, yet no general proof is known. This calculator does not claim to prove the conjecture.
For n equal to one the sequence is already finished: steps are zero, the peak is one, and the sequence is the singleton list containing one. For seven the path climbs through fifty-two before cascading down powers of two to one. For twenty-seven the trajectory is long and reaches a peak of nine thousand two hundred thirty-two, which makes it a favorite demonstration that a modest start can produce a surprisingly large intermediate value.
Intermediate odd terms whose three-n-plus-one step would leave the safe integer domain are also rejected rather than silently rounded. If you only need a single next term under the Collatz rule, apply the even or odd case yourself; this page answers the full-orbit question with steps, peak, and the complete sequence.
Where Collatz orbits fit in study, research demos, and code
Students meet the Collatz conjecture when exploring recreational number theory, discrete dynamical systems on the integers, and open problems that are easy to state but hard to settle. Teachers can generate answer keys for worksheets that ask for the stopping time of a start, the peak hailstone height, or the full trajectory, without trusting opaque calculator apps that hide intermediate terms. Developers use the same contract to validate sample data for number-theory libraries, to seed property tests, or to pre-compute expected sequences before a demonstration step.
Contest practice often needs a fast offline source of Collatz answers so solutions can be checked without downloading OEIS tables or writing a throwaway script under time pressure. Researchers and science communicators use short orbits as illustrations when explaining why a simple local rule can produce irregular long-term behavior.
What you can do with it
Homework and contest hailstone counts
Compute Collatz step counts, peaks, and full sequences for worksheets and contest checks without manual long arithmetic or ad-hoc scripts.
Teaching the 3n+1 problem
Show students how a simple even-odd rule produces long, climbing trajectories while they change n live in the browser at no cost.
FAQ
What does the Collatz conjecture calculator cost?
It is free in your browser on this page.
What happens if n is below 1?
Collatz sequences are defined here only for positive integers n ≥ 1.
How is the sequence computed?
Start at n. While the current value is not 1: if it is even, replace it with half of itself; if it is odd, replace it with three times itself plus one. Count each replacement as one step and track the maximum value seen, including the start.
Is the algorithm randomized?
No. It uses deterministic integer arithmetic only. The same n always yields the same sequence, step count, and peak.
Does this prove the Collatz conjecture?
No. It computes the finite orbit of one starting value under the 3n+1 map. The general conjecture remains an open problem in number theory.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/numth/collatz \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":7}'const res = await fetch("https://api.kit.forhosting.com/numth/collatz", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 7
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/collatz",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 7
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/collatz", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":7}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":7}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/collatz", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": 7
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.collatz",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Use it free in the browser for homework, contest prep, and conjecture exploration, or call the API at $0.002 per successful request when you automate grading scripts, teaching demos, or pipelines that need reproducible Collatz orbits.
What the Collatz map is and what the response contains
It computes the concrete orbit of a single starting value: the ordered list of terms from n through one, the step count (how many applications of the map are needed), the peak (the largest term that appears, including the start when n is already the maximum), and the length of that list, which is always steps plus one. Missing fields, non-integers, fractions, scientific notation, values outside the safe integer range, and any n below one fail with invalid_input and a clear message.
How inputs are read and how the sequence stays exact
Optional leading plus signs are allowed for positive values; embedded spaces, hex prefixes, and exponential notation are rejected so a bad cell does not become a wrong orbit. Negative integers and zero are rejected because this calculator defines Collatz sequences on positive integers starting at one. Even steps simply halve the current value and always stay within range once the previous term was safe. The preferred field is n as a JSON integer, but decimal strings and the aliases number, value, or start are accepted so forms, spreadsheets, and query strings can reuse one contract. The engine stays inside JavaScript safe integers for the input and for every intermediate term: when an odd term is so large that three times that term plus one would leave the safe range, the request fails with invalid_input instead of producing a rounded IEEE double that would corrupt the rest of the path. A defensive maximum step budget protects the Worker from a pathological hang, but ordinary classroom and contest values finish in far fewer iterations. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing the map yourself.
Where Collatz orbits fit in study, research demos, and code
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result. Pair it with prime factorization when you need prime powers, with an nth-prime calculator when you need the n-th prime, and with other numth tools when you are building a small number-theory lab of free, deterministic endpoints.
Integration use cases
Deterministic test fixtures
Generate reproducible Collatz orbits for unit tests, property checks, and CI assertions that fix known starting values and expected stopping times.