Check if a number is prime

Type a whole number. MathBuddy tests it for prime factors and shows the factorization step by step.

Loading math input...

What this page covers

  • Checking whether a whole number is prime by testing primes up to its square root.
  • Prime factorization, written with powers, such as 360 = 2³ · 3² · 5.
  • Listing or counting the primes below a number.
  • Not covered here: tests for numbers with hundreds of digits. To reduce a fraction with these factors, use Calculator with fractions.

How to enter the problem

  • Type the question with the number, such as Is 221 prime? or Prime factorization of 360.
  • Scan it. Fit the one problem in the frame.
  • Choose a photo. Several problems in one photo are solved as a list.
  • Then tap Solve.

Worked examples

Example 1

Problem

Is 221\displaystyle 221 prime?

Answer

Verified

The answer is

221=13⋅17221 = 13 \cdot 17

Explanation

  1. Decide how far to test
    221≈14.9\sqrt{221} \approx 14.9, so only the primes 2,3,5,7,11,132, 3, 5, 7, 11, 13 need testing.
  2. Rule out the small primes
    221221 is odd, its digit sum 55 is not a multiple of 33, and it does not end in 00 or 55. 221÷7221 \div 7 and 221÷11221 \div 11 leave remainders.
  3. Try 13
    221÷13=17221 \div 13 = 17 exactly.
  4. Conclude
    221221 has the factors 1313 and 1717, so it is not prime.

Example 2

Problem

Write 360\displaystyle 360 as a product of primes.

Answer

Verified

The answer is

360=23⋅32⋅5360 = 2^3 \cdot 3^2 \cdot 5

Explanation

  1. Divide by 2 while you can
    360→180→90→45360 \to 180 \to 90 \to 45: three factors of 22.
  2. Divide by 3 while you can
    45→15→545 \to 15 \to 5: two factors of 33.
  3. Stop at a prime
    55 is prime, so the factorization is complete.
  4. Write it with powers

Example 3

Problem

How many prime numbers are less than 50\displaystyle 50?

Answer

Verified

The answer is

1515

Explanation

  1. Choose the primes to sieve with
    50≈7.1\sqrt{50} \approx 7.1, so crossing out multiples of 2,3,52, 3, 5 and 77 is enough.
  2. Cross out the multiples
    From 22 to 4949, remove every multiple of 2,3,5,72, 3, 5, 7 except those primes themselves.
  3. List what is left
    2,3,5,7,11,13,17,19,23,29,31,37,41,43,472, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47.
  4. Count
    There are 1515 numbers in the list.

Common mistakes

  • Counting 1 as a prime. A prime has exactly two factors, 1 and itself, and 1 has only one.
  • Calling a number prime because it is odd and looks unfamiliar: 51=3⋅1751 = 3 \cdot 17 and 91=7⋅1391 = 7 \cdot 13.
  • Stopping a factorization early, such as 360=23⋅3⋅5360 = 2^3 \cdot 3 \cdot 5, which is 120120, not 360360.
  • Testing every number up to n. Testing the primes up to the square root of n is enough.

Checks, assumptions and limits

  • Multiply the factors back together: 23⋅32⋅5=8⋅9⋅5=3602^3 \cdot 3^2 \cdot 5 = 8 \cdot 9 \cdot 5 = 360.
  • Prime and composite apply to whole numbers greater than 1. The numbers 0 and 1 are neither.
  • 2 is the only even prime, so any other even number is composite.
  • MathBuddy can make mistakes. Double check important steps.

Frequently asked questions

No. A prime has exactly two different factors, 1 and itself. The number 1 has only one factor, so it is neither prime nor composite.

If n = a × b and both a and b were larger than the square root of n, their product would be larger than n. So every factor pair has one member at or below the square root.

Choose a photo of the list. Several problems in one photo are solved as a list. You can also type each number as its own question.

1 math question to try today without signing in, 3 a day signed in, unlimited with Pro.

Ready to solve your next math problem?

Try one problem free in your browser. Create a free account for 3 math questions a day.

Last updated: · MathBuddy