The proof that the square root of any prime number is irrational is easy using prime decomposition. We use proof by contradiction: suppose that sqrt(n) is rational. Then

n = a2/b2

for some a and b. Now write a and b as products of prime factors, and cancel any common factors. Then we have

n = p12×p22×···/q12×q22×···

where p1, p2, …, q1, q2, … are primes and pj≠qk for all j, k. (This is just a fancy way of saying there are no common factors.)

But n is an integer. Therefore the denominator q12×q22×… is equal to unity. If it were not, then the numerator would have a common factor with the denominator, since it would be an integer multiple of the denominator; but we already cancelled all common factors.

Therefore, if sqrt(n) is rational, n is a product of squares of integers, and not a prime. In fact we have proved a stronger statement: the square root of any non-square number is irrational. Thus, the square root of any integer is either an integer, or irrational.

The original statement has a slightly more elegant proof using the fundamental theorem of arithmetic, to be precise the fact that the prime decomposition is unique. If sqrt(n) is rational, then

n×b2 = a2.

The prime decomposition is unique, therefore the number of prime factors must be the same on both sides. Both a2 and b2, being squares, have an even number of prime factors. But n is prime. Therefore the LHS has an odd number of prime factors, and we have a contradiction. This also proves that the square root of any integer with an odd number of prime factors is irrational.