What would be the complexity of this program in mathematical terms ?
int main()
{
int k = 1, n;
cin >> n; //User Input
while(k < n)
{
k = 7*k+5;
}
}
This will be approached differently from the conventional "divide and conquer". The complexity might practically be O(1). But theoretically, it is not.The point is what would be the approach to solve such questions?
The term '5' in 'k = 7*k+5' is not as insignificant as it seems, for it is included in multiplication with each iteration. We will get the sequence - '1, 12, 89, 628, 4401, 30812' for n = 100000. That is the catch in the question. That is the actual problem I wanted to address. Kindly be considerate while voting on the question.