Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class UtilizandoFunçõesDeRetornoFatorialDeUmNumero {
  3.  
  4. public static void main(String[] args) {
  5. System.out.println("Digite um número para obter o valor de seu fatorial\n");
  6. Scanner Leitura=new Scanner(System.in);
  7. int numero=Leitura.nextInt();
  8. System.out.println("O fatorial de "+ numero+" é "+Fatorial(numero));
  9. Leitura.close();
  10. }
  11.  
  12. public static int Fatorial (int numero) {
  13. if((numero==1) || (numero==0)){
  14. return 1;
  15. }
  16. else
  17. {
  18. return numero * Fatorial(numero-1);
  19. }
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement