Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class BoucleDiviseur {
  5.  
  6. /**
  7. * @param args
  8. */
  9. public static void main(String[] args) {
  10. // TODO Auto-generated method stub
  11.  
  12. //Création de scanner
  13. Scanner input = new Scanner(System.in);
  14.  
  15. //Déclaration de variables
  16. int valeur = 0;
  17. int div=1;
  18. int cpt=0;
  19.  
  20. //Insertion des données
  21. System.out.println("Veuillez insérer une valeur:");
  22. valeur = input.nextInt();
  23.  
  24. //tests calculs
  25.  
  26. for (div = 1; (div*div)<valeur; div++) {
  27.  
  28. if (valeur%div == 0) {
  29. System.out.println(div);
  30. cpt++;
  31. }
  32. }
  33.  
  34. System.out.println("Nombre de diviseurs: " + cpt);
  35.  
  36.  
  37.  
  38.  
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement