Advertisement
ecube8

recursion

Sep 16th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.18 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. long main(void) {
  4.     long in;
  5.     scanf("%d", &in);
  6.     printf("%d\n", sq_sum(in));
  7.     return 0;
  8. }
  9.  
  10. long sq_sum(long n) {
  11.     if (n<=0) return 0;
  12.     return n*n+sq_sum(n);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement