title: Sum Largest Prime Factor Number Less Equal N
signature: fun sumLargestPrimeFactorNumberLessEqualN(n: Int): Int {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(6, 15)
      println("TEST-0...${result}")
      
      result = driver(35, 291)
      println("TEST-1...${result}")
      
      result = driver(87, 1554)
      println("TEST-2...${result}")
      
      result = driver(91, 1672)
      println("TEST-3...${result}")
      
      result = driver(63, 875)
      println("TEST-4...${result}")
      
      result = driver(11, 43)
      println("TEST-5...${result}")
      
      result = driver(66, 901)
      println("TEST-6...${result}")
      
      result = driver(17, 90)
      println("TEST-7...${result}")
      
      result = driver(92, 1695)
      println("TEST-8...${result}")
      
      result = driver(81, 1334)
      println("TEST-9...${result}")
      
          
  }
  
  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;
  }