fork download
  1. #include <stdio.h>
  2. int rec(int n){
  3. if (n == 1){
  4. return 1;
  5. }
  6. else{
  7. return n+rec(n-2);
  8. }
  9. }
  10. int main(void) {
  11. int n = 11;
  12. printf("%d以下の正の奇数の和は%d\n", n, rec(n));
  13. return 0;
  14. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
11以下の正の奇数の和は36