Advertisement
cesarnascimento

fatorial

Jun 26th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. package matriz;
  2. import java.util.Scanner;
  3. public class xd {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         Scanner sc = new Scanner(System.in);
  8.         int num;
  9.         int fat = 1;
  10.        
  11.        
  12.         System.out.println("numero");
  13.         num = sc.nextInt();
  14.         for(int i = num; i>0;i--){
  15.             System.out.println(i);
  16.             fat *=i;
  17.             if(num == 0){
  18.                 fat = 1;
  19.             }
  20.         }
  21.         System.out.println(fat);
  22.     }
  23.     /* César N. */
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement