Let’s prove that if , then either is an integer, or else it is irrational. (Cf. Abbott, Understanding analysis, Exercise 1.2.1.) There are many proofs of this fact. I present three.
The standard proof of this fact uses the prime factorization of : There is a unique way of writing as , where the are distinct primes numbers, and the are positive integers (the number corresponds to the empty product, but since is a square, we may as well assume in what follows that ).
We show that if is rational, then in fact each is even, so is actually an integer. Write where are integers that we may assume relatively prime. This gives us that .
Consider any of the primes in the factorization of . Let and be the largest powers of that divide and , respectively, say and where does not divide either of and . Similarly, write , where does not divide ( is what we called above). We have
The point is that since is prime, it does not divide or : If is a prime and divides a product (where are integers), then divides or it divides .
This means that either is even (as we wanted to show), so that , or else (upon dividing both sides of the displayed equation by the smaller of and ), divides one of the two sides of the resulting equation, but not the other, a contradiction.
The above is the standard proof, but there are other arguments that do not rely on prime factorizations. One I particularly like uses Bézout theorem: If is the greatest common divisor of the positive integers and , then there are integers such that .
Suppose . We may assume that are relatively prime, and therefore there are integers such that . The key observation is that . This, coupled with elementary algebra, verifies that
but the latter is an integer, and we are done.
Another nice way of arguing, again by contradiction, is as follows: Suppose that is not an integer, but it is rational. There is a unique integer with , so . Let be the least positive integer such that is an integer, call it . Note that , which gives us a contradiction if is again an integer. But this can be verified by a direct computation:
As a closing remark, the three arguments above generalize to show that is either an integer or irrational, for all positive integers . Similarly, if is rational for some positive integers , then both are th powers. (It is a useful exercise to see precisely how these generalizations go.)