Robert_Manea

nr prime java

Mar 3rd, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6.  
  7. package pkg40313;
  8. import java.util.*;
  9. /**
  10. *
  11. * @author L1PC08
  12. */
  13. public class Main {
  14.  
  15. /**
  16. * @param args the command line arguments
  17. */
  18. public static void main(String[] args) {
  19. int x,i,ok=1;
  20. Scanner ts=new Scanner(System.in);
  21. System.out.println("dati doua nr de la tastatura");
  22. x=ts.nextInt();
  23.  
  24. for(i=2;i<x/2;i++)
  25. if(x%i==0)ok=0;
  26. if(ok==0)
  27. System.out.println(x+" nu este prim");
  28. else
  29. System.out.println(x+"este prim");
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment