Advertisement
cesarnascimento

ex21 fernando repetição fatorial 2

May 30th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. package exercicios;
  2. import java.util.Scanner;
  3. public class ex17 {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         int num;
  8.        
  9.        
  10.         System.out.println("Digite o número: ");
  11.         num = sc.nextInt();
  12.        
  13.         System.out.println(num + "! = ");
  14.        
  15.         int fat = 1;
  16.         for(int i = num; i>0; i--){
  17.             fat *= i;
  18.             System.out.println(i);
  19.         }
  20.        
  21.         System.out.println(fat);
  22.        
  23.     }
  24.     /* César N. */
  25. }
  26.  
  27.  
  28. // calcular fatorial
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement