In reply to Ankur biswas.

No, it's not possible to solve this with brute force. You'll have to use math.