Find all factors of N and collect gems for each pair!
To find all factors of N, we only need to check from 1 to √N!
Why √N? If i divides N, then N/i also divides N. One
of them must be ≤ √N!
Time Complexity: O(√N) instead of O(N)