Your function assumes that all composite numbers above 10 are divisible by a number smaller than 10; not true.
Here's an article explaining some of the intricacies that go into finding prime numbers .
Keep in mind that the first method mentioned could be optimized more by only checking numbers smaller than sqrt(num) instead of num / 2.
Here's an article explaining some of the intricacies that go into finding prime numbers .
Keep in mind that the first method mentioned could be optimized more by only checking numbers smaller than sqrt(num) instead of num / 2.