title: Count Digits Factorial Set 2
signature: function count_digits_factorial_set_2(n)
source_py: def count_digits_factorial_set_2(n):
      if (n < 0):
          return 0
      if (n <= 1):
          return 1
      x = ((n * math.log10((n / math.e))) + (math.log10(((2 * math.pi) * n)) / 2.0))
      return (math.floor(x) + 1)
source_cpp: long long count_digits_factorial_set_2(int n) {
    if ( n < 0 ) return 0;
    if ( n <= 1 ) return 1;
    double x = ( ( n * log10 ( n / M_E ) + log10 ( 2 * M_PI * n ) / 2.0 ) );
    return floor ( x ) + 1;
  }
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(n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n) 
      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(56, 75)
      print(string.format("TEST-0...%s",result))
  
      result = driver(92, 143)
      print(string.format("TEST-1...%s",result))
  
      result = driver(52, 68)
      print(string.format("TEST-2...%s",result))
  
      result = driver(96, 150)
      print(string.format("TEST-3...%s",result))
  
      result = driver(96, 150)
      print(string.format("TEST-4...%s",result))
  
      result = driver(63, 88)
      print(string.format("TEST-5...%s",result))
  
      result = driver(51, 67)
      print(string.format("TEST-6...%s",result))
  
      result = driver(79, 117)
      print(string.format("TEST-7...%s",result))
  
      result = driver(70, 101)
      print(string.format("TEST-8...%s",result))
  
      result = driver(9, 6)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 75, "inputs": {"n": 56}}, {"idx": 1, "outputs": 143, "inputs": {"n": 92}}, {"idx": 2, "outputs": 68, "inputs": {"n": 52}}, {"idx": 3, "outputs": 150, "inputs": {"n": 96}}, {"idx": 4, "outputs": 150, "inputs": {"n": 96}}, {"idx": 5, "outputs": 88, "inputs": {"n": 63}}, {"idx": 6, "outputs": 67, "inputs": {"n": 51}}, {"idx": 7, "outputs": 117, "inputs": {"n": 79}}, {"idx": 8, "outputs": 101, "inputs": {"n": 70}}, {"idx": 9, "outputs": 6, "inputs": {"n": 9}}]
question_info.extension: lua
question_info.entry_fn_name: count_digits_factorial_set_2
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__