I would like to thank Recreations in the Theory of Numbers by Albert H. Beiler for this problem (#42 on page 299).