In computer science, a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number.For example, 5 is a prime number because it cannot be made by multiplying other natural numbers. 10 is a composite number because it can be made by multiplying 2 and 5.Prime numbers have many applications in cryptography, number theory, and other areas of mathematics.
Checking if a number is prime is a common task in programming. There are many different algorithms for checking primality, but one of the most common is the trial division algorithm.The trial division algorithm works by dividing the number by all of the prime numbers less than or equal to the square root of the number. If the number is divisible by any of these prime numbers, then it is not prime. Otherwise, it is prime.