Prime Numbers


A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.

This is what Wikipedia says about natural numbers: “In mathematics, the natural numbers are those used for counting (as in “there are six coins on the table”) and ordering (as in “this is the third largest city in the country”). In common language, words used for counting are cardinal numbers and words used for ordering are ordinal numbers.

An integer (from the Latin integer meaning “whole”) is a number that can be written without a fractional component. For example, 21, 4, 0, and −2048 are integers. Integers can be positive or negative or zero.

Some definitions, including the standard ISO 80000-2, begin the natural numbers with 0, corresponding to the non-negative integers 0, 1, 2, 3, …, whereas others start with 1, corresponding to the positive integers 1, 2, 3, …. Texts that exclude zero from the natural numbers sometimes refer to the natural numbers together with zero as the whole numbers, but in other writings, that term is used instead for the integers (including negative integers).

A natural number greater than 1 that is not a prime number is called a composite number. For example, 5 is prime because 1 and 5 are its only positive integer factors, whereas 6 is composite because it has the divisors 2 and 3 in addition to 1 and 6.

There are infinitely many primes, as demonstrated by Euclid around 300 BC. There is no known simple formula that separates prime numbers from composite numbers.

Primes are used in several routines in information technology, such as public-key cryptography, which makes use of properties such as the difficulty of factoring large numbers into their prime factors.

As you can see from the diagram below (from Wikipedia), the number 12 is not a prime, as 12 items can be placed into 3 equal-size columns of 4 each (among other ways). 11 items cannot be all placed into several equal-size columns of more than 1 item each without some extra items leftover (a remainder). Therefore, the number 11 is a prime.

Here is a list of the first 168 prime numbers (all the prime numbers less than 1000).

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, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997