The problem is easy if you know about the multiplicative group of integers mod 24. See Multiplicative group of integers modulo n - Wikipedia, the free encyclopedia.
Alternatively, for n less than 24, n=1, 5, 7, 11, 13, 17, 19 or 23 are the values prime to 24. By direct calculation each of these satisfy n2 is congruent to 1 mod 24. So any natural number n prime to 24 is congruent to one of these and you're done.