In number theory, Fermat studied Pell's equation, perfect numbers, amicable numbers and what would later become Fermat numbers. It was while researching perfect numbers that he discovered Fermat's little theorem. He invented a factorization method—Fermat's factorization method—and popularized the proof by infinite descent, which he used to prove Fermat's right triangle theorem which includes as a corollary Fermat's Last Theorem for the case "n" = 4. Fermat developed the two-square theorem, and the polygonal number theorem, which states that each number is a sum of three triangular numbers, four square numbers, five pentagonal numbers, and so on.