#include <stdio.h>
// 正の奇数nを引数として,n以下の正の奇数の和を求める関数
int rec(int n) {
if (n == 1) {
return 1; // 基本ケース: 1の場合
} else {
return n + rec(n - 2); // nまでの奇数の和
}
}
int main(void) {
int n = 3; // 正の奇数
printf("%d以下の正の奇数の和は%d\n", n
, rec
(n
)); // 出力 return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyDmraPjga7lpYfmlbBu44KS5byV5pWw44Go44GX44Gm77yMbuS7peS4i+OBruato+OBruWlh+aVsOOBruWSjOOCkuaxguOCgeOCi+mWouaVsAppbnQgcmVjKGludCBuKSB7CiAgICBpZiAobiA9PSAxKSB7CiAgICAgICAgcmV0dXJuIDE7IC8vIOWfuuacrOOCseODvOOCuTogMeOBruWgtOWQiAogICAgfSBlbHNlIHsKICAgICAgICByZXR1cm4gbiArIHJlYyhuIC0gMik7IC8vIG7jgb7jgafjga7lpYfmlbDjga7lkowKICAgIH0KfQoKaW50IG1haW4odm9pZCkgewogICAgaW50IG4gPSAzOyAvLyDmraPjga7lpYfmlbAKICAgIHByaW50ZigiJWTku6XkuIvjga7mraPjga7lpYfmlbDjga7lkozjga8lZFxuIiwgbiwgcmVjKG4pKTsgLy8g5Ye65YqbCiAgICByZXR1cm4gMDsKfQo=