##### Find the time complexity for the following C code segment.

GATE | GATE-CS-2007 | Question 51

Consider the following C code segment:

I think ans is A) , in madeeasy previous year book and geeksfogeeks shows B,Help me out |

GATE | GATE-CS-2007 | Question 51

Consider the following C code segment:

I think ans is A) , in madeeasy previous year book and geeksfogeeks shows B,Help me out |

While checking whether number is prime or not , we go from 1 to √n , until we get the no. divisible or until no. till √n gets exhausted.

Ex. for 169 , we check from 1 to 13

while for 150, we check till 2 only.

So, in worst case , its O(√n) and in best case its omega(1)

thank you i didn't see that return 0;