deez

Correction

Oct 9th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. public class Factorielle
  2. {
  3. public static void main(String[] args)
  4. {
  5. Scanner sc = new Scanner(System.in);
  6. System.out.println("Entrez un nombre n :");
  7. int n = sc.nextInt();
  8. int a=n-1;
  9.  
  10. int r=0;
  11. r=n*a;
  12. int result;
  13.  
  14. if (n<=0)
  15. {
  16. r=1;
  17. }
  18. else
  19. {
  20. while(a>1)
  21. {
  22. a=a-1;
  23. result=r*a;
  24. }
  25. }
  26. System.out.print("Le produit factoriel de "+n+" est : "+result);
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment