title: Program For Factorial Of A Number 2
signature: function program_for_factorial_of_a_number_2(n)
source_py: def program_for_factorial_of_a_number_2(n):
      return (1 if ((n == 1) or (n == 0)) else (n * program_for_factorial_of_a_number_2((n - 1))))
source_cpp: int program_for_factorial_of_a_number_2(int n) {
    return ( n == 1 || n == 0 ) ? 1 : n * program_for_factorial_of_a_number_2 ( n - 1 );
  }
question_info.entry_fn_name: program_for_factorial_of_a_number_2
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2']
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(2, 2)
      print(string.format("TEST-0...%s",result))
  
      result = driver(12, 479001600)
      print(string.format("TEST-1...%s",result))
  
      result = driver(11, 39916800)
      print(string.format("TEST-2...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 2, "inputs": {"n": 2}}, {"idx": 1, "outputs": 479001600, "inputs": {"n": 12}}, {"idx": 2, "outputs": 39916800, "inputs": {"n": 11}}]