Enter any positive whole number to find out instantly whether it is prime or composite. The checker uses trial division up to the square root of your number, lists all its factors, and explains the result.
A prime number has exactly two divisors: 1 and itself. This checker tests every candidate divisor from 2 up to the square root of your number. If none divide evenly, the number is prime.
For the number 97: the square root is about 9.85, so we only need to check divisors 2, 3, 5, 7. None divide 97 evenly, so 97 is prime.
Step 1: Find the square root of 97. sqrt(97) = 9.849, so we only need to test divisors from 2 up to 9.
Step 2: Test each candidate: 97 / 2 = 48.5 (no), 97 / 3 = 32.33... (no), 97 / 5 = 19.4 (no), 97 / 7 = 13.86... (no).
Step 3: No whole-number divisor was found between 2 and 9. Therefore 97 is prime. Its only factors are 1 and 97.
This matches the calculator output above with the default value of 97.
A prime number is a whole number greater than 1 that cannot be divided evenly by any number except 1 and itself. The first ten primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. Prime numbers are the building blocks of all whole numbers: every integer greater than 1 can be written as a unique product of primes (the Fundamental Theorem of Arithmetic).
A composite number is a positive integer greater than 1 that has at least one divisor other than 1 and itself. For example, 12 = 2 x 2 x 3. The number 1 is neither prime nor composite by mathematical convention.
The most straightforward primality test is trial division. To test whether n is prime, you divide n by every integer from 2 up to the square root of n. If any of these divisions has a whole-number result (no remainder), n is composite. If none do, n is prime.
Why stop at the square root? If n has a factor d greater than sqrt(n), then n / d is a factor smaller than sqrt(n), and you would already have found it during the earlier tests. So there is no need to test beyond the square root.
Example: for n = 36, sqrt(36) = 6. Testing 2, 3, 4, 5, 6 finds that 2 and 3 both divide 36, so 36 is composite. Its prime factorisation is 2 x 2 x 3 x 3 = 2² x 3².
| Number | Classification | Reason |
|---|---|---|
| 1 | Neither prime nor composite | Has only one positive divisor (itself) |
| 2 | Prime | The only even prime; divisible only by 1 and 2 |
| 0 | Neither prime nor composite | Not a positive integer; divisible by every non-zero integer |
| Negative integers | Not applicable | Primality is defined for positive integers only |
Large prime numbers underpin modern cryptography. RSA encryption relies on the fact that multiplying two large primes is easy, but factoring the result back into its prime components is computationally hard. A typical RSA key uses primes with hundreds of digits. The difficulty of finding prime factors of very large numbers is the mathematical foundation of secure internet transactions.
Method: Trial division to floor(sqrt(n)). For each candidate divisor d from 2 to floor(sqrt(n)), the checker tests whether n mod d = 0. If any remainder is zero, n is composite and all factors are listed. If no divisor is found, n is prime. Prime factorisation uses repeated division by the smallest prime factor until the quotient reaches 1.
This checker handles positive integers. Very large numbers (above 10 trillion) may be slow to process in some browsers due to JavaScript integer precision limits. For cryptographic-grade primality testing of extremely large numbers, specialist tools using probabilistic algorithms such as Miller-Rabin are recommended.
If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.
Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.
Calculate.co.nz is the sister site of CalculatorHub.com, the world's largest calculator website by tool count.
All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.
Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.
Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.
Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.
All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.
About & trust: Why Calculate is NZ's most comprehensive · By the Numbers · How we compare · Editorial standards · How we keep data current · NZ finance glossary · Research & data · Financial literacy NZ · About · Privacy policy · Terms of use
Reviewed and maintained. Last reviewed 2026-07-02 and checked on a twice-monthly cycle against IRD, RBNZ and Stats NZ. How we keep data current.
© 2026 Calculate.co.nz. All rights reserved. Building free NZ calculators since 2011.