# Big O Nested For Loop Breakdown

I understand how to get a general picture of the big O of a nested loop, but what would be the operations for each loop in a nested for loop?

If we have:

``````for(int i=0; i<n; i++)
{
for(int j=i+1; j<1000; j++)
{
do something of constant time;
}
}
``````

How exactly would we get T(N)? The outer for loop would be n operations, the inner would be 1000(n-1) and the inside would just be c is that right?

So `T(n)=cn(1000(n-1))` is that right?

• Where did you get 1000(n-1) ? Look again. Sep 30, 2015 at 0:16
• Should it be 1000-(n-1)? Sep 30, 2015 at 0:30
• Oops meant 1000-(n+1) Sep 30, 2015 at 1:59
• This will always remain O(n) since this algorithm will always scale linear. There is no logarithmic increase or decrease to be found. Obviously with higher N's this will take longer, but it will be a linear scaling always. Sep 30, 2015 at 8:24
• I'll just leave this here. (If you click "more terms" enough times, you will see the maximum, after which this is no longer accurate) Sep 30, 2015 at 17:52