Huh. I'd read that before but I'd forgotten about it.
Anyway, so far as I can see it has to be essentially trial and error to find the right answer, although there are a few ways to reduce the parameter space:
- k is odd.
- k is greater than 24.
- k is not prime (this is based on Fermat's last Theorem that states if p is prime then a^p mod p = a).
- k is not divisible by 9 (this is currently just Engineers' induction, but 3^(9n) mod 9n appears to produce a result that is always itself divisible by 9. I don't know if there's a way to see this automatically. Probably it's obvious really).
I think this reduces the parameter space (for odd numbers below 100) to, say,
25 33 35 39 49 51 55 57 65 69 75 77 85 87 91 93
which is at least only 16 numbers to test, rather than 100. They'll all come up short though, and indeed you have to press on to 721. With Mathematica I'm able to test thousands of numbers at once (and don't even have to look carefully), and it seems that 721 is the only answer that works up to 100,000 (trying to test up to a million, taking a little longer than hoped).
My suspicion is that you probably have to know how to program this, as I'm not seeing any obvious patterns. In particular, while most of the time the answer to 3^k mod k is divisible by 3, sometimes it is not -- the numbers for which this result fails are 49, 85, 115, 125, 133, 145, 169, 175, 185, 205, 215, 217 ...
I'm coming up short at the moment for a general method. There are ways to reduce the difficulty of the computation as, for example, 3^721 mod 721 is the same thing as ((3^300 mod 721)*(3^421 mod 721) )mod 721, or ((3^200 mod 721)*(3^521 mod 721) )mod 721, so that you can reduce the computation difficulty a little.
Just be grateful that you weren't asked to find (by hand) the least value k for which 3^k mod k = 26 (which is 4343), or =29 (25,517 and then 46,891).