Advertisement
cesarnascimento

fatorial

May 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.36 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class kkk {
  3.  
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         int soma = 1,n;
  7.        
  8.         System.out.println("valor:");
  9.         n = sc.nextInt();
  10.        
  11.         if (n==0 || n == 1){
  12.             soma = 1;
  13.         }
  14.        
  15.         for (int i = n; i > 1; i--){
  16.             soma *= i;
  17.         }
  18.        
  19.         System.out.println("valor: "+soma);
  20.  
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement