title: Sum Largest Prime Factor Number Less Equal N
signature: function sum_largest_prime_factor_number_less_equal_n(n)
source_py: def sum_largest_prime_factor_number_less_equal_n(n):
      prime = ([0] * (n + 1))
      sum = 0
      max = int((n / 2))
      for p in range(2, (max + 1)):
          if (prime[p] == 0):
              for i in range((p * 2), (n + 1), p):
                  prime[i] = p
      for p in range(2, (n + 1)):
          if prime[p]:
              sum += prime[p]
          else:
              sum += p
      return sum
source_cpp: int sum_largest_prime_factor_number_less_equal_n(int n) {
    int prime [ n + 1 ], sum = 0;
    memset ( prime, 0, sizeof ( prime ) );
    int max = n / 2;
    for ( int p = 2;
    p <= max;
    p ++ ) {
      if ( prime [ p ] == 0 ) {
        for ( int i = p * 2;
        i <= n;
        i += p ) prime [ i ] = p;
      }
    }
    for ( int p = 2;
    p <= n;
    p ++ ) {
      if ( prime [ p ] ) sum += prime [ p ];
      else sum += p;
    }
    return sum;
  }
question_info.entry_fn_name: sum_largest_prime_factor_number_less_equal_n
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 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(6, 15)
      print(string.format("TEST-0...%s",result))
  
      result = driver(35, 291)
      print(string.format("TEST-1...%s",result))
  
      result = driver(87, 1554)
      print(string.format("TEST-2...%s",result))
  
      result = driver(91, 1672)
      print(string.format("TEST-3...%s",result))
  
      result = driver(63, 875)
      print(string.format("TEST-4...%s",result))
  
      result = driver(11, 43)
      print(string.format("TEST-5...%s",result))
  
      result = driver(66, 901)
      print(string.format("TEST-6...%s",result))
  
      result = driver(17, 90)
      print(string.format("TEST-7...%s",result))
  
      result = driver(92, 1695)
      print(string.format("TEST-8...%s",result))
  
      result = driver(81, 1334)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 15, "inputs": {"n": 6}}, {"idx": 1, "outputs": 291, "inputs": {"n": 35}}, {"idx": 2, "outputs": 1554, "inputs": {"n": 87}}, {"idx": 3, "outputs": 1672, "inputs": {"n": 91}}, {"idx": 4, "outputs": 875, "inputs": {"n": 63}}, {"idx": 5, "outputs": 43, "inputs": {"n": 11}}, {"idx": 6, "outputs": 901, "inputs": {"n": 66}}, {"idx": 7, "outputs": 90, "inputs": {"n": 17}}, {"idx": 8, "outputs": 1695, "inputs": {"n": 92}}, {"idx": 9, "outputs": 1334, "inputs": {"n": 81}}]