fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int a[30], n, i;
  5. i=0;
  6. a[0]=2;
  7. a[1]=-1;
  8. for(n=2;n<30;n++){
  9. a[n]=-a[n-1]+a[n-2]+2;
  10. }
  11. while(a[i]<5000){
  12. i++;
  13. }
  14. printf("%d項目,%d",i,a[i]);
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
18項目,7754