fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a_prev_prev = 3; // a_0
  5. int a_prev = 0; // a_-1
  6. int index = 0;
  7.  
  8. while (1) {
  9. index++;
  10. int current_value = 2 * a_prev - a_prev_prev;
  11. if (current_value > 10000) {
  12. printf("Value: %d\n", current_value);
  13. printf("Index: %d\n", index);
  14. break;
  15. }
  16. a_prev_prev = a_prev;
  17. a_prev = current_value;
  18. }
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.49s 5308KB
stdin
Standard input is empty
stdout
Value: 2147483647
Index: 715827883