Advertisement
Guest User

Untitled

a guest
Oct 5th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int soma(int n)
  4. {
  5. if(n==1)
  6. {
  7. return 1;
  8. }
  9. else
  10. {
  11. return(n+soma(n-1));
  12. }
  13. }
  14.  
  15. int main()
  16. {
  17. int n;
  18.  
  19. printf("Digite um inteiro positivo: ");
  20. scanf("%d",&n);
  21.  
  22. printf("Soma: %d\n",soma(n));
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement