What is the fastest algorithm to determine if any number in a sorted array is multiple of `x`?

Viewed 3040

Given an positive integer x and a sorted positive integer array A

Is there any algorithm faster than O(N) to determine if any element in A is a multiple of x? There are no negative elements in A.

Naive looping A once is my only idea so far, I do not know if there is any way to make use of the fact that A is sorted to speed it up.

6 Answers
Related