title: Fibonacci Modulo P
signature: function fibonacci_modulo_p(p)
source_py: def fibonacci_modulo_p(p):
      first = 1
      second = 1
      number = 2
      next = 1
      while next:
          next = ((first + second) % p)
          first = second
          second = next
          number = (number + 1)
      return number
source_cpp: int fibonacci_modulo_p(int p) {
    int first = 1, second = 1, number = 2, next = 1;
    while ( next ) {
      next = ( first + second ) % p;
      first = second;
      second = next;
      number ++;
    }
    return number;
  }
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(p, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(p) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(51, 36)
      print(string.format("TEST-0...%s",result))
  
      result = driver(40, 30)
      print(string.format("TEST-1...%s",result))
  
      result = driver(68, 18)
      print(string.format("TEST-2...%s",result))
  
      result = driver(7, 8)
      print(string.format("TEST-3...%s",result))
  
      result = driver(8, 6)
      print(string.format("TEST-4...%s",result))
  
      result = driver(32, 24)
      print(string.format("TEST-5...%s",result))
  
      result = driver(93, 60)
      print(string.format("TEST-6...%s",result))
  
      result = driver(75, 100)
      print(string.format("TEST-7...%s",result))
  
      result = driver(71, 70)
      print(string.format("TEST-8...%s",result))
  
      result = driver(15, 20)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 36, "inputs": {"p": 51}}, {"idx": 1, "outputs": 30, "inputs": {"p": 40}}, {"idx": 2, "outputs": 18, "inputs": {"p": 68}}, {"idx": 3, "outputs": 8, "inputs": {"p": 7}}, {"idx": 4, "outputs": 6, "inputs": {"p": 8}}, {"idx": 5, "outputs": 24, "inputs": {"p": 32}}, {"idx": 6, "outputs": 60, "inputs": {"p": 93}}, {"idx": 7, "outputs": 100, "inputs": {"p": 75}}, {"idx": 8, "outputs": 70, "inputs": {"p": 71}}, {"idx": 9, "outputs": 20, "inputs": {"p": 15}}]
question_info.extension: lua
question_info.entry_fn_name: fibonacci_modulo_p
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__