title: Find Index Given Fibonacci Number Constant Time
signature: function findIndexGivenFibonacciNumberConstantTime(n: number): number {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(5, 5);
    console.log(`TEST-0...${result}`);
  
    result = driver(19, 8);
    console.log(`TEST-1...${result}`);
  
    result = driver(7, 6);
    console.log(`TEST-2...${result}`);
  
    result = driver(94, 12);
    console.log(`TEST-3...${result}`);
  
    result = driver(58, 11);
    console.log(`TEST-4...${result}`);
  
    result = driver(65, 11);
    console.log(`TEST-5...${result}`);
  
    result = driver(69, 11);
    console.log(`TEST-6...${result}`);
  
    result = driver(96, 12);
    console.log(`TEST-7...${result}`);
  
    result = driver(80, 11);
    console.log(`TEST-8...${result}`);
  
    result = driver(14, 8);
    console.log(`TEST-9...${result}`);
  
  };
  
  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;
  }