Help on a mathematics(algorithm) problem?

Problem: Given n (n<=100) integers a[i] (1<=i<=n && 1<=a[i]<=1 billion). Find all m>1 satisfying:
a[1] % m = a[2] % m = a[3] % m = … = a[n] % m.
Input: n and n integers a[i]
Output: all possible m (all input will have a solution)

Please help me on this problem!

1 Like