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. while(a[i]<5000){
  11. i++;
  12. }
  13. printf("%d項目 %d",i,a[i]);
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
18項目 7754