Prime numbers and their properties were first studied extensively by the ancient Greek mathematicians. The mathematicians of Pythagoras's school (500 BC to 300 BC) were interested in numbers for their mystical and numerological properties. They understood the idea of primality and were interested in perfect and amicable numbers. A perfect number is one whose proper divisors sum to the number itself. e.g. The number 6 has proper divisors 1, 2 and 3 and 1 + 2 + 3 = 6, 28 has divisors 1, 2, 4, 7 and 14 and 1 + 2 + 4 + 7 + 14 = 28. A pair of amicable numbers is a pair like 220 and 284 such that the proper divisors of one number sum to the other and vice versa.You can see more about these numbers in the History topics article Perfect numbers. By the time Euclid's Elements appeared in about 300 BC, several important results about primes had been proved. In Book IX of the Elements, Euclid proves that there are infinitely many prime numbers. This is one of the first proofs known which uses the method of contradiction to establish a result. Euclid also gives a proof of the Fundamental Theorem of Arithmetic: Every integer can be written as a product of primes in an essentially unique way. Euclid also showed that if the number 2n - 1 is prime then the number 2n-1(2n - 1) is a perfect number. The mathematician Euler (much later in 1747) was able to show that all even perfect numbers are of this form. It is not known to this day whether there are any odd perfect numbers. In about 200 BC the Greek Eratosthenes devised an algorithm for calculating primes called the Sieve of Eratosthenes. There is then a long gap in the history of prime numbers during what is usually called the Dark Ages. The next important developments were made by Fermat at the beginning of the 17th Century. He proved a speculation of Albert Girard that every prime number of the form 4 n + 1 can be written in a unique way as the sum of two squares and was able to show how any numbe...