Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. package Prvocisla;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Prvocisla {
  6.  
  7.  
  8.  
  9. public static void main(String[] args) {
  10.  
  11. Scanner input = new Scanner (System.in);
  12. System.out.println("Napis cislo: ");
  13. int sc = input.nextInt();
  14. int pocet = 0;
  15.  
  16. for(int i = 1; i <= sc; i++){
  17.  
  18. if(sc % i == 0){
  19. pocet++;
  20. }
  21. }
  22.  
  23. if (pocet == 2){
  24. System.out.println("Je to prvocislo");
  25. } else {
  26. System.out.println("Neni to prvocislo");
  27. }
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement