Advertisement
ahamed210

recursion1

Nov 5th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.20 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int function(int n)
  4. {
  5.     if(n < 1) return 0;
  6.     return n + function(n-1);
  7. }
  8.  
  9. int main()
  10. {
  11.     int n;
  12.     scanf("%d", &n);
  13.     printf("%d\n", function(n));
  14.     return 0;
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement