Testing and Finding Prime Numbers

ebdundar's avatarBraincycle

Prime numbers are numbers can only be divided by itself and 1.  They are greater than 0. In this text, we will see how to test whether a number is a prime number or not. Furthermore, we will find prime numbers up to N. ( N is a number entered by user. )

For example,  2 can be divided by 2 and 1. So it is a prime number.

Prime numbers: 2, 3, 5, 7, 11 ,13, 17, 19, …

How to test a number ?

“A” is a positive number greater than 1. Let X be a number different than number A and 1. If we can find such a number divide A with remainder 0, A is not a prime number.

  • X can be preferred prime numbers less than square root of A. This make our program slightly faster.

A : 29 and Square root of A : 5.385164

View original post 80 more words

Unknown's avatar

Author: mathtuition88

Math and Education Blog

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.