fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. int a[50],i;
  6. a[0]=2;
  7. a[1]=-1;
  8. for(i=0;a[i]<=5000;i++){
  9. a[i+2]=-1*a[i+1]+a[i]+2;
  10. }
  11. printf("%d %d",a[i],i);
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
7754 18