It is certainly not a homework assignment. I'm more interested in number
theory than Mathematica and I have little time to give to it.
I didn't know that I was supposed to show what I tried, but in any case it
wasn't worth exhibiting. Your approach is very helpful.
I received about at least three different approaches -- all
interesting. Bob Hanlon sent me the same one as Jean-Marc, and that is the
one I am modifying to use.