Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int soma(int n)
- {
- if(n==1)
- {
- return 1;
- }
- else
- {
- return(n+soma(n-1));
- }
- }
- int main()
- {
- int n;
- printf("Digite um inteiro positivo: ");
- scanf("%d",&n);
- printf("Soma: %d\n",soma(n));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement