void fun() { int i, j; for (i=1; i<=n; i++) for (j=1; j<= log (i); j++) printf ( "GeeksforGeeks" ); } |
Time Complexity of the above function can be written as which is
Order of growth of and
is same for large values of
, i.e.,
. So time complexity of fun() is
.
The expression can be easily derived from following Stirling’s approximation (or Stirling’s formula).
Read full article from A Time Complexity Question | GeeksforGeeks