I\'ve been interested in the problem of finding a better prime number recognizer for years. I realize this is a huge area of academic research and study - my interest in this i
The time complexity of your program is O(n*m^0.5)
. With n
the number of primes in the input. And m
the size of the biggest prime in the input, or MAX_INT
if you prefer. So complexity could also be written as O(n)
with n the number of primes to check.
With Big-O, n
is (usually) the size of the input, in your case that would be the number of primes to check. If I make this list twice as big (for example duplicating it), it would take (+-) exactly twice as long, thus O(n)
.