fact(n) は,非負の整数nに対してnの階乗を返す。fact(n) の再帰的な定義はどれか。
- if n=0 then 0 else return n×fact(n−1)
- if n=0 then 0 else return n×fact(n+1)
- if n=0 then 1 else return n×fact(n−1)
- if n=0 then 1 else return n×fact(n+1)
解答
ウ
解説
- if n=0 then 0 else return n×fact(n−1)
作成中 - if n=0 then 0 else return n×fact(n+1)
作成中 - if n=0 then 1 else return n×fact(n−1)
作成中 - if n=0 then 1 else return n×fact(n+1)
作成中
参考情報
分野・分類
分野 | テクノロジ系 |
大分類 | 基礎理論 |
中分類 | アルゴリズムとプログラミング |
小分類 | アルゴリズム |
出題歴
- AP 平成29年度秋期 問7
- AP 平成25年度春期 問6