[ create a new paste ] login | about

Link: http://codepad.org/gLN1ZaIM    [ raw code | fork ]

axell13 - C, pasted on Oct 29:
import java.util.Scanner;

public class JavaYahoo {
    
    public static int verificaPrimo(Integer n){
        Integer np = 0;
        
        for(int i = 1; i <= n; i++){
            
            if (n % i == 0){
                np += 1;
            }
            
        }
        
        if (np == 2){
            return 1;
        }
        else {
            return 0;
        }
        
    }
    
    public static void Escrever(Integer n, Integer retur){
        if (retur == 1){
            System.out.printf("\n%d É Primo\n", n);
        }
        else if (retur == 0){
            System.out.printf("\n%d Não É Primo\n", n);
        }
        else {
            System.out.printf("\nOcorreu Algum Erro\n");
        }
    }
    
    public static void main(String[] args){
        Integer n = 0;
        Scanner cin = new Scanner(System.in);
        
        System.out.printf("Informe O Inteiro: ");
        n = cin.nextInt();
        Escrever(n, verificaPrimo(n));
        cin.nextLine();
        cin.nextLine();
    }
    
}


Create a new paste based on this one


Comments: