fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. using ll = long long;
  5.  
  6. ll S(int n) {
  7. return n < 2 ? 1 : S(n - 1) + n;
  8. }
  9.  
  10. int main() {
  11. // your code goes here
  12. int n;
  13. scanf("%d", &n);
  14. printf("S(%d) = %d", n, S(n));
  15. return 0;
  16. }
Success #stdin #stdout 0s 5308KB
stdin
10
stdout
S(10) = 55