Advertisement
Jkljk

exercicios recursividade

Aug 7th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. /*
  2. 1 - implemente uma funรงao recursiva que recebe x e n, calcule
  3. o valor de x;
  4. 2 - implemente uma funรงao recursi va que recebe um vetor x, seu tamanho t
  5. e retorna a soma dos valores de x.
  6. 3 - mdc (x,y)=?
  7. mdc(x-y,y), se x>y
  8. mdc(y,x) se x<y
  9. mdc(x,x)=x
  10. 4 - implemente a funรงao recursiva soma(n) que retorna o somatorio dos n primeiro numeros
  11. a partir de 1*/
  12.  
  13. //1 -
  14. #include <stdio.h>
  15. int pot(int x, int n){
  16. if(n==0) return(1);
  17. else return(x*pot(x,n-1));
  18. }
  19.  
  20. //2
  21. #include <stdio.h>
  22. int exerc(int x[], int n){
  23. if(n==0) return(0);
  24. else return x[n-1]+exerc(x,n-1);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement