title: Find Index Given Fibonacci Number Constant Time
signature: find_index_given_fibonacci_number_constant_time <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          5L, 
          5L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          19L, 
          8L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          7L, 
          6L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          94L, 
          12L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          58L, 
          11L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          65L, 
          11L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          69L, 
          11L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          96L, 
          12L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          80L, 
          11L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          14L, 
          8L
      )))
  
  }
  
  main()
source_py: def find_index_given_fibonacci_number_constant_time(n):
      if (n <= 1):
          return n
      a = 0
      b = 1
      c = 1
      res = 1
      while (c < n):
          c = (a + b)
          res = (res + 1)
          a = b
          b = c
      return res
source_cpp: int find_index_given_fibonacci_number_constant_time(int n) {
    if ( n <= 1 ) return n;
    int a = 0, b = 1, c = 1;
    int res = 1;
    while ( c < n ) {
      c = a + b;
      res ++;
      a = b;
      b = c;
    }
    return res;
  }