fork download
  1. #include <stdio.h>
  2.  
  3. int sum(int m, int n) {
  4. if (m > n)
  5. return 0;
  6. else
  7. return m + sum(m + 1, n);
  8.  
  9. }
  10.  
  11. int main() {
  12. int a, b;
  13. scanf("%d %d", &a, &b);
  14.  
  15. if (a > 0 && b > 0 && a <= b) {
  16. int S = sum(a, b);
  17. printf("%d \n",S);
  18. }
  19.  
  20. return 0;
  21. }
  22.  
  23.  
Success #stdin #stdout 0s 5316KB
stdin
1 2
stdout
3