Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. int wynikR = 0;
  2. int j;
  3. int[] tab = new int[1000];
  4. int index = 999;
  5. for (int i=0; i<=index; i++)
  6. {
  7. tab[i] = i;
  8. }
  9. int max = (int)Math.sqrt(999);
  10.  
  11. for(int i=2; i<=max; i++)
  12. {
  13. if(tab[i] != 0)
  14. {
  15. j = i*2;
  16. while(j<=index)
  17. {
  18. tab[j] = 0;
  19. j+=i;
  20. }
  21. }
  22. }
  23. for(int i = 100; i<=index; i++)
  24. {
  25. if(tab[i] !=0)
  26. {
  27. wynikR++;
  28. }
  29. }
  30. System.out.println("Wszystkich liczb pierwszych i trzycyfrowych jest: " +wynikR);
  31. break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement