Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Factorielle
- {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in);
- System.out.println("Entrez un nombre n :");
- int n = sc.nextInt();
- int a=n-1;
- int r=0;
- r=n*a;
- int result;
- if (n<=0)
- {
- r=1;
- }
- else
- {
- while(a>1)
- {
- a=a-1;
- result=r*a;
- }
- }
- System.out.print("Le produit factoriel de "+n+" est : "+result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment