Create a file for the Primality Test calculator function
This function has 1 integer input and outputs whether prime or not.
By definition a prime number doesn't have any divisors other than 1 and itself. A composite number has at least one additional divisor, let's call it d. Naturally nd is also a divisor of n. It's easy to see, that either d≤n−−√ or nd≤n−−√, therefore one of the divisors d and nd is ≤n−−√. We can use this information to check for primality.
We try to find a non-trivial divisor, by checking if any of the numbers between 2 and n−−√ is a divisor of n. If it is a divisor, than n is definitely not prime, otherwise it is.
Todo
Create a file for the Primality Test calculator function
This function has 1 integer input and outputs whether prime or not. By definition a prime number doesn't have any divisors other than 1 and itself. A composite number has at least one additional divisor, let's call it d. Naturally nd is also a divisor of n. It's easy to see, that either d≤n−−√ or nd≤n−−√, therefore one of the divisors d and nd is ≤n−−√. We can use this information to check for primality.
We try to find a non-trivial divisor, by checking if any of the numbers between 2 and n−−√ is a divisor of n. If it is a divisor, than n is definitely not prime, otherwise it is.
Example
Important
Guidelines for adding new functions are clearly mentioned in the contributing guidelines.
Screenshots of the output needs to be added along with the PRs for quicker merges.
If any queries, discuss it in the issue thread.