Advertisement
cesarnascimento

ex3 for repetiçao livro primeiros

May 8th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. package pkgfor;
  2.  
  3. import java.util.Scanner;
  4. public class For {
  5.  
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.         int qtd,i,num,fatorial,j;
  10.         System.out.println("Digite a quantidade de números para serem lidos: ");
  11.         qtd = sc.nextInt();
  12.        
  13.         for(i=1;i<=qtd;i++){
  14.             System.out.println("Digite o " +i+ "º número:");
  15.             num = sc.nextInt();
  16.             fatorial = 1;
  17.             for (j=1;j<=num;j++)
  18.                 fatorial = fatorial * j;
  19.             System.out.println("O fatorial de "+num+" é: "+fatorial);
  20.                
  21.                 }
  22.        
  23.     }
  24.    
  25. }
  26. // receber uma x quantidade de numeros
  27. // essa quantidade de numeros vai ser de escolha do usuario
  28. // os numeros escolhidos deveram ser mostrado o fatorial.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement