Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Primes
- {
- static String res="";
- static int cnt=0;
- public static void Primes(int p)
- {
- if(p<2)
- {
- System.out.println("Veuillez saisir un entier >=2");
- }
- else
- {
- for(int j=2;j<=p;j++)
- {
- for(int i=1;i<=j/2;i++)
- {
- if(j%i==0)
- {
- cnt+=1;
- }
- }
- if(cnt==1)
- {
- res+=j+" ";
- }
- cnt=0;
- }
- System.out.println("resultat :"+res);
- }
- }
- public static void main(String arg[])
- {
- Primes(19);
- //System.out.println(5%2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement