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