Problem

Source: Romania 2017 IMO TST 4, problem 1

Tags: number theory



Let m be a positive interger, let $p$ be a prime, let $a_1=8p^m$, and let $a_n=(n+1)^{\frac{a_{n-1}}{n}}$, $n=2,3...$. Determine the primes $p$ for which the products $a_n(1-\frac{1}{a_1})(1-\frac{1}{a_2})...(1-\frac{1}{a_n})$, $n=1,2,3...$ are all integral.