Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. package listes;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Scanner;
  5.  
  6. public class Premier {
  7.  
  8. boolean test;
  9.  
  10. public Premier() {
  11.  
  12. //saisie de la valeur de m (limite superieur)
  13.  
  14. System.out.println("Veuillez saisir la limite superieur");
  15. Scanner scan=new Scanner(System.in);
  16. int m= scan.nextInt();
  17.  
  18. //saisie de la taille n de la liste
  19.  
  20. System.out.println("Veuillez saisir la taille de la liste");
  21. Scanner scan2=new Scanner(System.in);
  22. int n= scan2.nextInt();
  23.  
  24.  
  25. //creation de la table ArrayList
  26. ArrayList <String> tab= new ArrayList<>();
  27.  
  28. for( int i=0; tab.size()<=n; )
  29. {
  30. int valeur=(int)(Math.random() * ((m - 2) + 1)) + 2;
  31.  
  32. if (valeur<=m)
  33. {
  34. for(int i=1;i<=valeur/2;i++)
  35. {
  36. if(valeur%i==0)
  37. {
  38. test=true;
  39. }
  40. else {
  41. test=false;
  42. }
  43. }
  44. }
  45. }
  46. System.out.println(m);
  47. }
  48.  
  49.  
  50. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement