title: Sum Of All Proper Divisors Of A Natural Number
signature: sum_of_all_proper_divisors_of_a_natural_number <- function(num) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      abs(actual - expected) < 1e-06
  }
  
  driver <- function(num, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(num), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          2L, 
          1.0
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          57L, 
          23.0
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          28L, 
          28.0
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          43L, 
          1.0
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          38L, 
          22.0
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          29L, 
          1.0
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          45L, 
          33.0
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          47L, 
          1.0
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          44L, 
          40.0
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          3L, 
          1.0
      )))
  
  }
  
  main()
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 );
  }