Senin, 24 Oktober 2011

flowchart dan netbeans bilangan prima


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package riezal;

import java.util.Scanner;

/**
 *
 * @author TOSHIBA
 */
public class Bilangan_prima {
    public static void main(String[] args) {

       int n;
        System.out.println("\n Masukkan Angka yang akan diuji = ");
        Scanner input = new Scanner (System.in) ;
        n = input.nextInt();

        boolean isPrime = false;
    if (n >= 2) {
        isPrime = true;
       for (int z = 2; z < n; z++) {
        if (n % z== 0) {

                isPrime = false;

            }
        }
    }
    System.out.println("the answer is " + isPrime);
}
}




Tidak ada komentar:

Posting Komentar