daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top