wap to display a no is prime or not

import java.util.Scanner;

public class prime
{
    public static void main(String args[])
    {
        int num, i, count=0;
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter a Number : ");
        num = scan.nextInt();
        for(i=2; i<num; i++)
        {
            if(num%i == 0)
            {
                count++;
                break;
            }
        }
        if(count == 0)
        {
            System.out.print("This is a Prime Number");
        }
        else
        {
            System.out.print("This is not a Prime Number");
        }
    }
}

Comments

Popular posts from this blog

A story of friendship A tiger and a rat......become a revengable....

best pen drive

wap to perform subtraction