fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. int n,x[1000];
  6. x[0] = 1;
  7.  
  8. for(n = 0;n < 1000;n ++){
  9. if((x[n+1] = 2 * x[n] + 1) >= 1000){
  10. printf("この数列が初めて1000を超えたときのnの値は%dです。\n",n+2);
  11. break;
  12. }
  13. }
  14.  
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
この数列が初めて1000を超えたときのnの値は10です。