title: Count Factorial Numbers In A Given Range
signature: function count_factorial_numbers_in_a_given_range(low, high)
source_py: def count_factorial_numbers_in_a_given_range(low, high):
      fact = 1
      x = 1
      while (fact < low):
          fact = (fact * x)
          x += 1
      res = 0
      while (fact <= high):
          res += 1
          fact = (fact * x)
          x += 1
      return res
source_cpp: int count_factorial_numbers_in_a_given_range(int low, int high) {
    int fact = 1, x = 1;
    while ( fact < low ) {
      fact = fact * x;
      x ++;
    }
    int res = 0;
    while ( fact <= high ) {
      res ++;
      fact = fact * x;
      x ++;
    }
    return res;
  }
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(low, high, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(low, high) 
      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(57, 79, 0)
      print(string.format("TEST-0...%s",result))
  
      result = driver(57, 21, 0)
      print(string.format("TEST-1...%s",result))
  
      result = driver(31, 37, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(62, 87, 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver(49, 98, 0)
      print(string.format("TEST-4...%s",result))
  
      result = driver(82, 76, 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver(31, 45, 0)
      print(string.format("TEST-6...%s",result))
  
      result = driver(5, 52, 2)
      print(string.format("TEST-7...%s",result))
  
      result = driver(76, 43, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver(55, 6, 0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"low": 57, "high": 79}}, {"idx": 1, "outputs": 0, "inputs": {"low": 57, "high": 21}}, {"idx": 2, "outputs": 0, "inputs": {"low": 31, "high": 37}}, {"idx": 3, "outputs": 0, "inputs": {"low": 62, "high": 87}}, {"idx": 4, "outputs": 0, "inputs": {"low": 49, "high": 98}}, {"idx": 5, "outputs": 0, "inputs": {"low": 82, "high": 76}}, {"idx": 6, "outputs": 0, "inputs": {"low": 31, "high": 45}}, {"idx": 7, "outputs": 2, "inputs": {"low": 5, "high": 52}}, {"idx": 8, "outputs": 0, "inputs": {"low": 76, "high": 43}}, {"idx": 9, "outputs": 0, "inputs": {"low": 55, "high": 6}}]
question_info.extension: lua
question_info.entry_fn_name: count_factorial_numbers_in_a_given_range
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__