回答編集履歴

1

for を while に変更

2020/05/07 15:47

投稿

kazuma-s
kazuma-s

スコア8224

test CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  else if (n == 2) r = n2;
18
18
 
19
- else for (int i = 3; i <= n; i++) r = n1 + n2, n1 = n2, n2 = r;
19
+ else while (--n > 1) r = n1 + n2, n1 = n2, n2 = r;
20
20
 
21
21
  return *result = r;
22
22