Problem

Source: KJMO 2022 P3

Tags: number theory, prime numbers



For a given odd prime number p, define f(n) the remainder of d divided by p, where d is the biggest divisor of n which is not a multiple of p. For example when p=5, f(6)=1,f(35)=2,f(75)=3. Define the sequence a1,a2,,an, of integers as the followings: a1=1 an+1=an+(1)f(n)+1 for all positive integers n. Determine all integers m, such that there exist infinitely many positive integers k such that m=ak.