title: Sum Largest Prime Factor Number Less Equal N
signature: sum_largest_prime_factor_number_less_equal_n <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          6L, 
          15L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          35L, 
          291L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          87L, 
          1554L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          91L, 
          1672L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          63L, 
          875L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          11L, 
          43L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          66L, 
          901L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          17L, 
          90L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          92L, 
          1695L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          81L, 
          1334L
      )))
  
  }
  
  main()
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;
  }