Wednesday, 11 December 2013

Unknown

Write a program to Find whether number is Prime or Not.



class PrimeNo {

    public static void main(String args[]) {
        int num = Integer.parseInt(args[0]);
        int flag = 0;
        for (int i = 2; i < num; i++) {
            if (num % i == 0) {
                System.out.println(num + " is not a Prime Number");
                flag = 1;
                break;
            }
        }
        if (flag == 0) {
            System.out.println(num + " is a Prime Number");
        }
    }
}

Unknown

About Blog No Baap -

Since 2016 BlogNoBaap has been bringing you the very best in all types of web resources. Posted daily, and delivered straight to your inbox each morning.

Subscribe to this Blog via Email :