SHARE
TWEET

bhreae

a guest Mar 18th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. int cont=0;
  3. int main()
  4. {
  5.     //testando o algoritmo para os numeros 6,15,20
  6.     int N[3]={6, 15, 20}, i;
  7.     for(i=0; i<3; i++){
  8.         printf("%i! = %i. E houveram %i chamadas recursivas\n",
  9.         N[i], fatorial(N[i]), cont);
  10.     }
  11.     printf("E houveram %i chamadas recursivas", cont);
  12.     return 0;
  13. }
  14. int fatorial(int n){
  15.     cont++;
  16.     if(n==1)
  17.         return n;
  18.     else
  19.         return n * fatorial(n-1);
  20.        
  21. }
  22. //podemos ver que há um erro de representação
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top