Guest User

Untitled

a guest
Feb 11th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. /**
  2. * Beschreiben Sie hier die Klasse SoNguyenTo.
  3. *
  4. * Viết code in ra màn hình số nguyên tố từ 10..1000
  5. *
  6. * @author PhucVo
  7. * @version 2019
  8. */
  9.  
  10. public class SoNguyento
  11. {
  12. public void snt()
  13. {
  14. for(int i = 10; i < 100; i++)
  15. {
  16. if(checkSNT(i))
  17. {
  18. System.out.println(i + "");
  19. }
  20. }
  21. }
  22.  
  23. public boolean checkSNT(int a)
  24. {
  25. if(a < 2)
  26. {
  27. return false;
  28. }
  29. for(int i = 2; i < a; i++ )
  30. {
  31. if(a % i == 0)
  32. {
  33. return false;
  34. }
  35. }
  36. return true;
  37. }
  38. }
Add Comment
Please, Sign In to add comment