There are different methods to verify if a number is prime, but one common method is the trial division method:
- Start with the number n that you want to test for primality.
- Find the square root of n and round it up to the nearest integer. Call this number m.
- Check if n is divisible by 2 or 3. If it is, then n is not prime.
- Start with i=5 and check if n is divisible by i or i+2. Continue this process up to m. If none of the numbers in this interval divide n, then n is prime.
For example, to test if 23 is prime:
- Start with n=23.
- The square root of 23 is about 4.8, so m=5.
- 23 is not divisible by 2 or 3.
- Check if 23 is divisible by 5 or 7. Since neither 5 nor 7 divide 23, we can conclude that 23 is prime.