Click here to Skip to main content
15,909,503 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, what is time complexity for the prime number function , i took function as
IsPrime(int n)?

What I have tried:

i have designed an algorithm with three important cases.
let "i" be the integer
1.i<2 it returns false.
2.i==2 it returns true.
3.i%2==0 it returns false.
is this the way to know the complexity of prime number??
Posted
Updated 21-Sep-16 9:10am

1 solution

Your algorithm have nothing to do with prime integers.
your algorithm is missing in the result when i%2 != 0.

Since your algorithm have nothing to do with prime integers, there is no complexity answer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900