I was trying to solve this problem. When I failed to come up with a memory efficient solution, I looked at some AC solutions.
Interestingly, the solutions used a property that states that the minimum number that has a phi value greater than or equal to a given number, must be the first prime number greater than the given number. For example, For 20, the answer is 23. I am looking for a proof of this property.
Edit: According to tfg's comment, the answer isn't necessarily a prime number always. But this "property" holds for the given range of numbers due to prime gap.