title: Sum Of All Proper Divisors Of A Natural Number
signature: function sumOfAllProperDivisorsOfANaturalNumber(num: number): number {
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.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}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return Math.abs(actual - expected) < 1e-06;
  }
  
  function driver(num: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(num),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(2, 1.0);
    console.log(`TEST-0...${result}`);
  
    result = driver(57, 23.0);
    console.log(`TEST-1...${result}`);
  
    result = driver(28, 28.0);
    console.log(`TEST-2...${result}`);
  
    result = driver(43, 1.0);
    console.log(`TEST-3...${result}`);
  
    result = driver(38, 22.0);
    console.log(`TEST-4...${result}`);
  
    result = driver(29, 1.0);
    console.log(`TEST-5...${result}`);
  
    result = driver(45, 33.0);
    console.log(`TEST-6...${result}`);
  
    result = driver(47, 1.0);
    console.log(`TEST-7...${result}`);
  
    result = driver(44, 40.0);
    console.log(`TEST-8...${result}`);
  
    result = driver(3, 1.0);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: sumOfAllProperDivisorsOfANaturalNumber
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js