Problem suggested to me by Lucas Garron. Thanks to extra work done by Josh Laison, Jan Van Lent and Tarim (which convinced me it would work as a puzzle).
CORRECTIONS: - Actually, more of a clarification. In the first bit I was using a remainder of 0 as 6, according to the convention that n = 0, mod n. But I forgot to mention it explicitly. Sorry! First noticed by DeadLink.