Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. public static void main(String[] args)
  2. {
  3. // 10 pierwszych liczb - 2, 3, 5, 7, 11, 13, 17, 19, 23, 29
  4.  
  5. int licz = 0;
  6. int liczX = 0;
  7. for(int x = 2; x < 100; x++)
  8. {
  9. for(int i = 1; i < 101; i++)
  10. {
  11. if(liczX == 10)
  12. break;
  13.  
  14. if(x % i == 0)
  15. {
  16. licz++;
  17. }
  18. if(i == 100 && licz == 2)
  19. {
  20. System.out.println(x + " Jest liczbÄ… pierwsza!");
  21. licz = 0;
  22. liczX++;
  23. }
  24. else if(i == 100)
  25. {
  26. licz = 0;
  27. }
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement