title: Compute N Under Modulo P
signature: function compute_n_under_modulo_p(n, p)
source_py: def compute_n_under_modulo_p(n, p):
      if (n >= p):
          return 0
      result = 1
      for i in range(1, (n + 1)):
          result = ((result * i) % p)
      return result
source_cpp: int compute_n_under_modulo_p(int n, int p) {
    if ( n >= p ) return 0;
    int result = 1;
    for ( int i = 1;
    i <= n;
    i ++ ) result = ( result * i ) % p;
    return result;
  }
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, p, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n, 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(85, 18, 0)
      print(string.format("TEST-0...%s",result))
  
      result = driver(14, 13, 0)
      print(string.format("TEST-1...%s",result))
  
      result = driver(83, 21, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(30, 35, 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver(96, 51, 0)
      print(string.format("TEST-4...%s",result))
  
      result = driver(55, 58, 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver(82, 71, 0)
      print(string.format("TEST-6...%s",result))
  
      result = driver(12, 74, 44)
      print(string.format("TEST-7...%s",result))
  
      result = driver(38, 3, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver(46, 73, 67)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"n": 85, "p": 18}}, {"idx": 1, "outputs": 0, "inputs": {"n": 14, "p": 13}}, {"idx": 2, "outputs": 0, "inputs": {"n": 83, "p": 21}}, {"idx": 3, "outputs": 0, "inputs": {"n": 30, "p": 35}}, {"idx": 4, "outputs": 0, "inputs": {"n": 96, "p": 51}}, {"idx": 5, "outputs": 0, "inputs": {"n": 55, "p": 58}}, {"idx": 6, "outputs": 0, "inputs": {"n": 82, "p": 71}}, {"idx": 7, "outputs": 44, "inputs": {"n": 12, "p": 74}}, {"idx": 8, "outputs": 0, "inputs": {"n": 38, "p": 3}}, {"idx": 9, "outputs": 67, "inputs": {"n": 46, "p": 73}}]
question_info.extension: lua
question_info.entry_fn_name: compute_n_under_modulo_p
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__