title: Sum Of All Proper Divisors Of A Natural Number
signature: function sum_of_all_proper_divisors_of_a_natural_number(num)
source_py: def sum_of_all_proper_divisors_of_a_natural_number(num):
      result = 0
      i = 2
      while (i <= math.sqrt(num)):
          if ((num % i) == 0):
              if (i == (num / i)):
                  result = (result + i)
              else:
                  result = (result + (i + (num / i)))
          i = (i + 1)
      return (result + 1)
source_cpp: int sum_of_all_proper_divisors_of_a_natural_number(int num) {
    int result = 0;
    for ( int i = 2;
    i <= sqrt ( num );
    i ++ ) {
      if ( num % i == 0 ) {
        if ( i == ( num / i ) ) result += i;
        else result += ( i + num / i );
      }
    }
    return ( result + 1 );
  }
question_info.entry_fn_name: sum_of_all_proper_divisors_of_a_natural_number
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
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 math.abs(actual - expected) < 1e-06
  end
  
  function driver(num, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(num) 
      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, 1.0)
      print(string.format("TEST-0...%s",result))
  
      result = driver(57, 23.0)
      print(string.format("TEST-1...%s",result))
  
      result = driver(28, 28.0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(43, 1.0)
      print(string.format("TEST-3...%s",result))
  
      result = driver(38, 22.0)
      print(string.format("TEST-4...%s",result))
  
      result = driver(29, 1.0)
      print(string.format("TEST-5...%s",result))
  
      result = driver(45, 33.0)
      print(string.format("TEST-6...%s",result))
  
      result = driver(47, 1.0)
      print(string.format("TEST-7...%s",result))
  
      result = driver(44, 40.0)
      print(string.format("TEST-8...%s",result))
  
      result = driver(3, 1.0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 1, "inputs": {"num": 2}}, {"idx": 1, "outputs": 23.0, "inputs": {"num": 57}}, {"idx": 2, "outputs": 28.0, "inputs": {"num": 28}}, {"idx": 3, "outputs": 1, "inputs": {"num": 43}}, {"idx": 4, "outputs": 22.0, "inputs": {"num": 38}}, {"idx": 5, "outputs": 1, "inputs": {"num": 29}}, {"idx": 6, "outputs": 33.0, "inputs": {"num": 45}}, {"idx": 7, "outputs": 1, "inputs": {"num": 47}}, {"idx": 8, "outputs": 40.0, "inputs": {"num": 44}}, {"idx": 9, "outputs": 1, "inputs": {"num": 3}}]