Java program to check whether a given number is primenumber or not ?
Program to check whether a given number is primenumber or not ? 1. First of all , what is a primary number ? A primary number is a number, which can be divided by 1 and itself only. For example, 2,3,5 and so on. 2. Now, you know what is a primary number, How can you determine the given number is primary or not? you already know, a prime number, consider n, can have only 2 factors at any point of time i.e 1 & n. If any number between 1 and n divides n, then its not a prime number. 3. So, lets iterate from 2 upto n(exclusie) and check whether it can divide the number or not. If it divides then the given number is not a primary number else it is. The program is package numbertheory; public class PrimeChecker { public static void main(String[] args) { System.out.println(isPrime(100000007)); } public static boolean isPrime(int number) { for(int i = 2 ; i < number; i++) { if(number % i == 0) { System.out.println(i); return false; } }...