What is the estimated complexity of this program?

Revision en2, by LilyWhite, 2019-01-29 13:54:39
int n;
cin>>n;
if (n==0)//deal with it
for (double i=0;i<=1/(double)n;i+=1e-9)//do something

It seems that, this code runs faster when n becomes larger...

When n = 109, the code will be executed once. When n = 1, it runs 109 times.

So I estimated it as O(n - 1).

But, this means that this algorithm runs even faster than O(1).

How is it possible?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English LilyWhite 2019-01-29 13:54:39 0 (published)
en1 English LilyWhite 2019-01-29 13:54:00 437 Initial revision (saved to drafts)