I have a problem with a loop that requires a decreasing number of operations each time the loop executes. Here’s the code:
for (int i = 1; i < n; i++) {
...code that takes at most 100/i operations to execute...
}
I need to find a big O that describes the number of operations. I think what’s tripping me up here is that bigger n = more operations, but the growth is smaller.
Thanks for your help!
Harmonic number 1 + 1/2 + 1/3 + … + 1/n is O(log n)
Also, what if n > 100? For instance: Is 100/12345 operations well defined?