Number theory
Number theory is a branch of mathematics devoted primarily to the study of the integers. Any attempt to such a study naturally leads to an examination of the properties of that which integers are made of (namely, prime numbers) as well as the properties of objects made out of integers (such as rational numbers) or defined as generalisations of the integers (algebraic integers).
Origins
Given an equation or equations, can we find solutions that are integers? Solutions that are rational numbers? This is one of the basic questions of number theory. It seems to have been first addressed in ancient India (see Vedic number theory).
Hellenistic mathematicians had a keen interest in what would later be called number theory: Euclid devoted part of his Elements to prime numbers and factorization. Much later - in the third century CE - Diophantus would devote himself to the study of rational solutions to equations. Diophantus's treatise is the first known treatment of the subject that can be called by any stretch systematic. Some questions on divisibility and congruences were being studied elsewhere at the time (see Chinese remainder theorem).
In the next thousand years, Islamic mathematics dealt with some questions related to congruences, while Indian mathematicians of the classical period found the first systematic method for finding integer solutions to quadratic equations in the case in which such a problem is difficult (see Pell's equation).
Number theory started to flower in western Europe thanks to a renewed study of the works of Greek antiquity; the influence of mathematicians from the Islamic world as preservers and innovators also played a part. Fermat's careful reading of Diophantus's Arithmetica resulted spurred him to many new results and conjectures around which further research in the field crystallised.
Modern number theory is generally held to start with the work of Legendre (1798) and Gauss (Disquisitiones Arithmetica, 1801). Two of its first achievements were the law of quadratic reciprocity and the beginnings of a thorough study of quadratic forms.