Perfect square checker
Find out whether a whole number is a perfect square, or get the n-th square: 49 is a square with root 7, and square number 7 is 49. The test uses an exact whole-number root, never a rounded decimal. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Value
- 49
- N
- 7
- Nth square
- 49
- Root
- 7
- Root squared
- 49
The square number checker answers two everyday number-theory questions with one deterministic contract. First, given a non-negative index n, it returns the n-th perfect square — that is, n squared — so zero maps to zero, one maps to one, two maps to four, seven maps to forty-nine, and so on through the safe integer range. Second, given any integer value under test, it decides whether that value is itself a perfect square by computing an exact integer square root and checking that the root squared recovers the original number. Classic true cases include zero, one, four, nine, sixteen, twenty-five, thirty-six, forty-nine, and one hundred; non-squares such as two, three, five, and fifty return false with the floor root for context. The engine never uses floating-point square roots that could round near a boundary, never samples randomness, never reads the clock, and never calls the network.
What the n-th perfect square is and how membership is decided
A perfect square is a non-negative integer that can be written as k squared for some integer k greater than or equal to zero. Ordering those squares by the root gives the sequence of n-th perfect squares: the zeroth is zero, the first is one, the second is four, the third is nine, and the general term is simply n squared. This capability returns that term when you supply n, so you can build tables, fill worksheets, or seed tests without hand-multiplying large indices.
When you supply value instead — or in addition — the checker answers a different but related question: is this integer a perfect square at all? It does not guess with Math.sqrt and a tolerance. Zero is a perfect square with root zero; one is a perfect square with root one; forty-nine is a perfect square with root seven; forty-eight is not, and the floor root is six because thirty-six is the largest square at or below forty-eight.
Where perfect-square checks fit in study, coding practice, and automation
Students meet perfect squares early when learning multiplication tables, area of squares, Pythagorean triples, and later when sieving for square-free integers or testing quadratic residues in modular arithmetic. Teachers can generate answer keys for worksheets without trusting opaque calculator apps that hide floating-point roots. Developers use the same contract to validate sample data for number-theory libraries, to gate property tests on random integer generators, or to pre-check that a seed is a perfect square before a demonstration step that assumes an integer root.
Contest practice often needs a fast offline source of square membership so solutions can be checked without downloading OEIS tables or hard-coding lists of squares. Data pipelines that normalize catalog codes, puzzle IDs, or grid sizes sometimes need to reject non-squares before a downstream step that takes a square root as an integer dimension.
Pair it with a Kaprekar-number checker when you need digit splits of squares, with Lucas or Fibonacci tools when you need recurrence sequences, and with prime factorization when you need the prime signature of n rather than whether n is a square.
What you can do with it
Homework and contest classification
Decide whether integers are perfect squares and list the n-th square for worksheets and contest checks without floating-point roots.
Teaching roots and area models
Show students how n maps to n² and how isqrt recovers the root while they change inputs live in the browser at no cost.
FAQ
What does the perfect square checker cost?
It is free in your browser on this page.
What happens if value is negative?
Perfect squares are defined for non-negative integers, so a negative value cannot be tested as a perfect square here.
How is the perfect-square test computed?
The engine computes the integer square root of value with a binary search that multiplies candidates using exact BigInt arithmetic, then checks whether root squared equals value. No floating-point Math.sqrt is used.
Is the algorithm randomized?
No. It uses deterministic integer multiplication and binary-search isqrt.
What do I get when a number is not a perfect square?
A clear no, plus the whole-number root just below it and that root squared. For 48 the root is 6, because 36 is the largest square at or below 48, so you see the nearest lower square straight away.
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/math/square-number \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":7}'const res = await fetch("https://api.kit.forhosting.com/math/square-number", {
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/math/square-number",
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/math/square-number", 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/math/square-number", 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": "math.square_number",
"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
Negative values under test are rejected with invalid_input because perfect squares live on the non-negative integers. Explore free in the browser for homework, contest prep, and teaching demos, or call the API at $0.002 per successful request when grading scripts and pipelines need reproducible perfect-square answers.
What the n-th perfect square is and how membership is decided
It computes the integer square root root, the greatest integer such that root squared is less than or equal to value, then sets is_perfect_square to true only when root squared equals value exactly. If the value is not a square, is_perfect_square is false and root still reports the floor of the real square root, with root_squared equal to root times root so callers can see the nearest lower square without a second request. Missing both fields, non-integers, fractions, scientific notation, values outside the safe integer range, a negative index n, and any negative value under test all fail with invalid_input and a clear message. Non-square non-negative integers are successful responses with is_perfect_square false; they are not errors.
How inputs are read and how the integer square root stays exact
You must provide at least one of the two; supplying both returns the n-th square and the membership verdict in a single object. Negative n is rejected because the sequence of perfect squares is indexed from zero upward. Negative value is rejected with an explicit message: perfect squares are defined for non-negative integers, and this checker will not pretend a negative number has an integer square root in the reals that squares back to itself. The index field is n as a JSON integer, with aliases index and k so forms and query strings can reuse one contract. The membership field is value, with aliases x and number for the same reason. Optional leading plus signs are allowed on non-negative values; embedded spaces, hex prefixes, and exponential notation are rejected so a bad spreadsheet cell does not become a wrong boolean. Internally the n-th square multiplies with BigInt so intermediate products stay exact before the result is returned as a safe JSON number. The integer square root uses binary search over BigInt candidates, comparing mid times mid against the target value, so there is no IEEE double step that could round a near-miss into a false perfect square.
Where perfect-square checks fit in study, coding practice, and automation
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.
Integration use cases
Deterministic test fixtures
Generate reproducible square and non-square cases for unit tests, property checks, and CI assertions without embedding static tables.
Technical questions
What is the n-th perfect square?
It is n squared. For n = 0 the result is 0; for n = 1 it is 1; for n = 2 it is 4; for n = 7 it is 49. Supply the field n (or aliases index or k) to receive nth_square.