Primality by trial division: Difference between revisions

Content added Content deleted
m (Prime numbers moved to Primality by Trial Division: Making room for the new prime numbers category)
m (Added to prime numbers category)
Line 1: Line 1:
{{task}}Write a boolean function that tells whether a given integer is prime. Remember that 1 and all non-positive numbers are not prime.
{{task}}[[Category:Prime Numbers]]Write a boolean function that tells whether a given integer is prime. Remember that 1 and all non-positive numbers are not prime.


Use trial division. Even numbers may be eliminated right away. A loop from 3 to √(n) will suffice, but other loops are allowed.
Use trial division. Even numbers may be eliminated right away. A loop from 3 to √(n) will suffice, but other loops are allowed.