fact(n) は,非負の整数 n に対して n の階乗を返す。fact(n) の再帰的な定義はどれか。

テクノロジ系

ア if n=0 then return 0 else return n×fact(n−1)
イ if n=0 then return 0 else return n×fact(n+1)
ウ if n=0 then return 1 else return n×fact(n−1)
エ if n=0 then return 1 else return n×fact(n+1)

正解: ウ

要点: fact(0)=1、fact(n)=n×fact(n−1)。

詳しい解説と誤答の理由はアプリで

解き方や選択肢ごとの考え方を、アプリで確認できます。

App Storeでアプリを見る

関連キーワード: 再帰・階乗・アルゴリズム

同じ回の前後の問題

テクノロジ系の他の問題

別の年度の同じ分野の問題

アプリで弱点分析つきの演習ができます

App Store

応用情報技術者の学習アプリ(応用情報トレ)

出典:令和7年度 春期 応用情報技術者試験 午前 問7