Advertisement
d3dx939dll

Aula35 - Funções Recursivas

Jan 10th, 2021
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void){
  4.    
  5.     int fatorial (int x);
  6.     int numero, resultado;
  7.  
  8.     printf("Digite Um Numero: ");
  9.     scanf("%i", &numero);
  10.    
  11.     resultado = fatorial(numero);
  12.  
  13.     printf("O fatorial eh %i\n", resultado);
  14.  
  15.     return 0;
  16. }
  17. int fatorial(int x){
  18.     int resultado;
  19.     if(x ==0){
  20.         resultado = 1;
  21.     }else{
  22.         resultado = x * fatorial(x - 1);
  23.     }
  24.    
  25.     return resultado;
  26. }
  27.  
  28. //Sobre
  29.  
  30. //Aula: Funções Recursivas - (#35)
  31. //Video: youtube.com/watch?v=1kBiqUCN888
  32. //Artigo: linguagemc.com.br/recursividade-em-c/
  33.  
  34. //Autor: @d3dx939dll
  35. //Data: 11/01/2021
  36. //Grupo: Heikoa
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement