Banner 0
Banner 1
Banner 2
Banner 3
Banner 4
Banner 5
Banner 6
Banner 7
Banner 8
Banner 9

Q.

How to test if a number is prime up to 1000

see full answer

Your Exam Success, Personally Taken Care Of

1:1 expert mentors customize learning to your strength and weaknesses – so you score higher in school , IIT JEE and NEET entrance exams.
An Intiative by Sri Chaitanya

(Unlock A.I Detailed Solution for FREE)

Best Courses for You

JEE

JEE

NEET

NEET

Foundation JEE

Foundation JEE

Foundation NEET

Foundation NEET

CBSE

CBSE

Detailed Solution

For numbers up to 1,000, the most efficient manual method is Trial Division with an optimization.

The key optimization is that you only need to check for factors up to the square root of the number (n). If n has a factor larger than its square root, it must also have a factor smaller than it, which you would have already found.

Let's test if n = 97 is prime. The square root of 97 is ~9.8. We only need to check primes up to 9 (which are 2, 3, 5, 7).

Step 1: Is n <= 1? No. (97 is not 1).

Step 2: Is n = 2? No. (It's 97).

Step 3: Is n divisible by 2? 97 / 2 has a remainder. No.

Step 4: Check odd divisors from 3 up to sqrt(n), which is ~9.8. We check 3, 5, 7, 9.

  • Is 97 divisible by 3? 9+7=16. 16 is not divisible by 3. No.
  • Is 97 divisible by 5? It doesn't end in 0 or 5. No.
  • Is 97 divisible by 7? 97 / 7 = 13 with a remainder of 6. No.

Step 5: We have checked all prime divisors up to the square root of 97. Since none of them divided it evenly, 97 is prime.

Watch 3-min video & get full concept clarity
score_test_img

courses

No courses found

Ready to Test Your Skills?

Check your Performance Today with our Free Mock Test used by Toppers!

Take Free Test

Get Expert Academic Guidance – Connect with a Counselor Today!

best study material, now at your finger tips!

  • promsvg

    live classes

  • promsvg

    progress tracking

  • promsvg

    24x7 mentored guidance

  • promsvg

    study plan analysis

download the app

gplay
mentor

Download the App

gplay
whats app icon
personalised 1:1 online tutoring