fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a = 3; // 初期値 a0 = 3
  5. int index = 0; // インデックス(0番目からスタート)
  6.  
  7. // 数列を計算して10000を超える値を探す
  8. while (a <= 10000) {
  9. a = 2 * a - 1; // 次の値を計算
  10. index++; // インデックスを1増やす
  11. }
  12.  
  13. // 結果を表示
  14. printf("初めて10000を超える値: %d\n", a);
  15. printf("位置(何番目か): %d\n", index);
  16.  
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
初めて10000を超える値: 16385
位置(何番目か): 13