algorithms.tutorialhorizon.com

Check if given number is Prime - O(√N) Solution – Java Program | Algorithms

Given a number, write a program to check if the number is prime or not. Prime Number: A number is called a prime number when number is not divisible by 1 or by number itself. 1 is not considered as prime number. Example:N = 10, Output: '10' is not a prime number. Output: '13' is a prime number