How to find whether a given number is prime or not?

  • Context: MHB 
  • Thread starter Thread starter burgess
  • Start date Start date
  • Tags Tags
    Prime
Click For Summary
SUMMARY

A prime number is defined as a number greater than 1 that has exactly two factors: 1 and itself. To determine if a number A is prime, first calculate a whole number K that is greater than the square root of A. Then, check if A is divisible by any prime number less than K. If A is not divisible by any of these primes, it is confirmed as a prime number. For example, 337 is a prime number as it is not divisible by any prime numbers less than 19.

PREREQUISITES
  • Understanding of prime numbers and their properties
  • Basic knowledge of square roots and divisibility
  • Familiarity with programming concepts for algorithm implementation
  • Knowledge of algorithms for prime number testing
NEXT STEPS
  • Research the Sieve of Eratosthenes for efficient prime number generation
  • Learn about Fermat's Little Theorem for probabilistic primality testing
  • Explore the Miller-Rabin test for advanced prime number verification
  • Implement prime number checking algorithms in Python or C++ using resources from Geeks for Geeks
USEFUL FOR

Mathematicians, computer scientists, software developers, and students working on algorithms related to prime number identification and optimization.

burgess
Messages
23
Reaction score
0
What is a prime number

A number is greater than 1 is called a prime number, if it has only two factors, namely 1 and the number itself.

Prime numbers up to 100 are:2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97

Procedure to find out the prime number

Suppose A is given number.

Step 1: Find a whole number nearly greater than the square root of A. K > square root(A)
Step 2: Test whether A is divisible by any prime number less than K. If yes A is not a prime number. If not, A is prime number.

Example:

Find out whether 337 is a prime number or not?

Step 1: 19 > square root (337)
Prime numbers less than 19 are 2, 3, 5, 7, 11, 13, 17
Step 2: 337 is not divisible by any of them

Therefore 337 is a prime number

These are simple and easy tricks which are helpful to solve your math homework problems .
 
Physics news on Phys.org
Great summary! There are several other ways of determining if a given number is prime in addition to your method.

This article from Geeks for Geeks implements some algorithms in C++, Java, Python, C#, PHP, and Javascript because sometimes when you're developing an application you need to do this.

https://www.geeksforgeeks.org/prime-numbers/

and this article from Wikihow brings in several other schemes including Fermat's Little Theorem and Miller-Rabin test which dramatically speeds up the testing process but have pitfalls in identifying a number as prime when it is not aka false positive.

https://www.wikihow.com/Check-if-a-Number-Is-Prime
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 36 ·
2
Replies
36
Views
1K
  • · Replies 28 ·
Replies
28
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
9
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K