As n is in range of 5e5 therefore at least 25*10^10
number have to be check and we can’t do brute force on this.
How to approach this problem
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.