Right-Truncatable Prime Checker
Checks whether a prime stays prime as you remove its last digit again and again: 3797 gives 379, 37 and 3, all prime, so it passes. Each prefix is listed with its own result, up to fifteen digits. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- N
- 3797
- Truncations tested
- 4
A right-truncatable prime remains prime when its decimal digits are removed from the right, one at a time, all the way to a single digit. This checker evaluates the original integer and every required prefix, then returns a transparent trace showing which values are prime. It is useful for verifying number-theory exercises, inspecting generated candidates, and explaining why a number fails the definition. All arithmetic is deterministic and local, with no random witnesses, network requests, or hidden data sources involved.
What right truncation requires
A right-truncatable prime must pass a chain of primality tests, not just one test on the submitted number. Begin with the complete decimal representation, remove its final digit, test the remaining prefix, and repeat until only the first digit remains. For example, 3797 produces 3797, 379, 37, and 3.
Every member of that sequence is prime, so the original number satisfies the definition. The direction matters: removing digits from the left describes a different property, and rotating digits describes circular primes. This checker preserves that distinction by listing the exact sequence it examined.
How to provide n and interpret the response
Provide n as ordinary unsigned base-ten text without commas, spaces, a decimal point, exponent notation, or a leading plus sign. Leading zeros are rejected because they make the digit-removal sequence ambiguous: the integer 037 would numerically equal 37, yet its written prefixes would imply a different test. The accepted domain starts at two.
Zero, one, and negative values return an input error because they cannot begin the required chain with a prime number. Inputs may contain up to fifteen digits, keeping every value inside the exact deterministic range declared by this capability. A false overall answer includes the first composite prefix; a true answer omits that optional field rather than returning a null placeholder.
Why the result is deterministic and reproducible
The implementation uses exact BigInt arithmetic from input validation through every modular operation. It first rejects obvious composites using small prime divisors, then applies fixed-base Miller–Rabin checks to the remaining candidates. For the supported range below one quadrillion, the selected witnesses make the test deterministic: identical input always produces the same mathematical answer, with no probabilistic confidence level.
The algorithm never reads the clock, generates random values, contacts a service, or stores request data. Its work is tightly bounded as well. A fifteen-digit input creates exactly fifteen prefixes, and each primality check uses a fixed witness set with logarithmic modular exponentiation.
That makes the capability suitable for interactive exploration and repeatable automated validation. In either channel, the shared solver supplies the decision and trace, so the displayed result and programmatic result follow precisely the same rules.
What you can do with it
Verify a number-theory exercise
Check a proposed right-truncatable prime and show every required prime prefix as evidence.
Filter generated candidates
Apply a deterministic right-truncation predicate to candidate integers produced by a bounded search.
Teach digit-based prime properties
Display the complete truncation chain to contrast right truncation with left truncation, rotation, and ordinary primality.
FAQ
Is the original number tested too?
Yes. The full submitted number is the first value in the truncation chain and must itself be prime.
Does this remove digits from the left?
No. It removes the final, rightmost digit each time. Left-truncatable primes use a different test.
Why are leading zeros rejected?
Leading zeros do not change an integer's value but would change its written truncation sequence, so canonical decimal input avoids ambiguity.
Is the primality test probabilistic?
No. The fixed witnesses are deterministic throughout the capability's supported fifteen-digit range.
What does it show when a number fails?
It points to the first prefix that is not prime, counting from the full number toward the first digit. The rest of the chain is still listed, so you can inspect every step instead of a bare no.
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/right-truncatable-prime \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":"3797"}'const res = await fetch("https://api.kit.forhosting.com/numth/right-truncatable-prime", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": "3797"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/right-truncatable-prime",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": "3797"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/right-truncatable-prime", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":"3797"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":"3797"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/right-truncatable-prime", 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": "3797"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.right_truncatable_prime",
"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.
Limits
max_digits | 15 |
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
What right truncation requires
The is_right_truncatable_prime field gives the overall decision, while truncations pairs each decimal prefix with its individual primality result. If any prefix is composite, first_composite_truncation identifies the earliest failure encountered from the full number toward the first digit. The entire chain is still returned, allowing you to inspect later prefixes instead of receiving only a boolean with no supporting evidence.
How to provide n and interpret the response
In the response, n remains text so its submitted digits are represented exactly. truncations_tested equals the number of digits, because the original value and every shorter nonempty prefix are checked. Each object in truncations contains a text value and a prime boolean.
Technical questions
What happens when n is below two?
The request returns an invalid_input error because the supported domain begins at two.
What does an API request cost?
Each API request costs $0.002. The browser runner is available for interactive checks.