This prime counting calculator tells you exactly how many prime numbers exist up to and including any whole number you choose, the value mathematicians call pi(n). Primes, the numbers only divisible by themselves and one, thin out as numbers grow larger but never stop appearing, and there is no simple algebraic formula that predicts exactly how many exist below a given point. To get an exact answer you have to count them, which is what this tool does. Enter an upper limit n of up to 2,000,000 and the calculator runs a sieve of Eratosthenes, working through every number in that range and marking off multiples to identify every prime, before returning three results: the total count of primes less than or equal to n, the largest prime found within that range, and the upper limit you entered for reference. For example, entering 100 returns 25 primes, with 97 the largest. The two million ceiling keeps the sieve fast and light enough to run instantly in your browser rather than needing a server. For a quick sense check on bigger ranges, the prime number theorem suggests pi(n) is roughly n divided by the natural logarithm of n, though this calculator always gives you the exact count rather than an approximation. It is a handy tool for students, programmers and anyone curious about how primes are distributed across the number line.
pi(n) counts the primes p with p less than or equal to n. There is no simple closed formula, so the calculator builds a sieve of Eratosthenes and counts. For scale, the prime number theorem says pi(n) is roughly n divided by the natural logarithm of n.
Up to 100 the primes are 2, 3, 5, 7, 11 and so on up to 97, and there are 25 of them, so pi(100) = 25 with 97 the largest. Enter 100 to confirm.
pi(n) is the number of primes less than or equal to n. For example pi(10) = 4, counting 2, 3, 5 and 7.
No simple closed form. The prime number theorem approximates it as n over the natural log of n, but exact counts use a sieve.
The sieve needs an array of that size. Two million keeps it fast and memory light in the browser.
This calculator is for students, programmers and anyone exploring number theory.
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 by 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-08-15 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.