fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int a0=2;
  5. int a1=-1,a2;
  6. int n=0;
  7. while(1){
  8. a2=-a1+a0+2;
  9. if(a2>5000){
  10. printf("初めて5000を超えるのは:a[%d]\n",n+2);
  11. printf("その時の値:%d\n",a2);
  12. break;
  13. }
  14. a0=a1;
  15. a1=a2;
  16. n++;
  17. }
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
初めて5000を超えるのは:a[18]
その時の値:7754