# Find Index In Sorted Array Such That A[i] = C1 * i + C2

I'm already know that there is an algorithm that can solve A[i]=i in O(log(n)) in a sorted array. But I want to know if there is any kind of algorithm that also can solve A[i] = C1 * i + C2 (witch C1 and C2 are constant values) in O(log(n)) or not

• I'm having trouble understanding what task you want the algorithm to solve. Can you edit your question to explain your question in more detail? What is the input to the algorithm, and what do you want the output to be? I'm not sure what it means to "solve A[i]=i in a sorted array". What is the algorithm you are thinking of? Can you tell us about where you encountered this task? Can you give us any more context? It might also be helpful to tell us about what approaches you've considered and what is the fastest algorithm you have found so far. Thank you! – D.W. Aug 7 at 19:40
• @D.W., if I understood correctly, given a sorted array, Problem 1: find $i$ such that $A[i]=i$. Problem 2: given $C_1, C_2$ find $i$ such that $A[i] =C_1 \cdot i + C_2$. – Dmitry Aug 7 at 19:57
• Are you sure Problem 1 can be solved in $O(\log n)$ time? Can you show the algorithm in the question? – D.W. Aug 7 at 21:22
• there is an algorithm that can solve A[i]=i in $O(\log(n))$ in a sorted array can you please provide a reference or a sketch? – greybeard Aug 9 at 1:15