1

I am newbie in time complexity.Probably the question may be very easy.

public void test(int n)
{
  for(int i=1;i<=n;i=i*5)
  {
      System.out.println(i);
  }
}

Above code has one loop and the frequency of the loop is determined by (i=i*5). Can someone help to find time complexity of below code.

nayak0765
  • 101
  • 8

1 Answers1

0

The algorithm has time complexity O(log n). Since the multiplication is by 5, specifically we can say that the time complexity is of the order of log n to the base 5.

Deepu
  • 7,406
  • 4
  • 23
  • 47