title: Sum Subsets Set Formed First N Natural Numbers
signature: function sumSubsetsSetFormedFirstNNaturalNumbers(n: number): number {
source_py: def sum_subsets_set_formed_first_n_natural_numbers(n):
      return (((n * (n + 1)) / 2) * (1 << (n - 1)))
source_cpp: unsigned long long sum_subsets_set_formed_first_n_natural_numbers(int n) {
    return ( n * ( n + 1 ) / 2 ) * ( 1 << ( n - 1 ) );
  }
question_info.test_list: [{"idx": 0, "outputs": 11777605632.0, "inputs": {"n": 26}}, {"idx": 1, "outputs": 10823317585920.0, "inputs": {"n": 35}}, {"idx": 2, "outputs": 5111011082240.0, "inputs": {"n": 34}}, {"idx": 3, "outputs": 530579456.0, "inputs": {"n": 22}}, {"idx": 4, "outputs": 24.0, "inputs": {"n": 3}}, {"idx": 5, "outputs": 5452595200.0, "inputs": {"n": 25}}, {"idx": 6, "outputs": 530579456.0, "inputs": {"n": 22}}]
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-09;
  }
  
  function driver(n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(26, 11777605632.0);
    console.log(`TEST-0...${result}`);
  
    result = driver(35, 10823317585920.0);
    console.log(`TEST-1...${result}`);
  
    result = driver(34, 5111011082240.0);
    console.log(`TEST-2...${result}`);
  
    result = driver(22, 530579456.0);
    console.log(`TEST-3...${result}`);
  
    result = driver(3, 24.0);
    console.log(`TEST-4...${result}`);
  
    result = driver(25, 5452595200.0);
    console.log(`TEST-5...${result}`);
  
    result = driver(22, 530579456.0);
    console.log(`TEST-6...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: sumSubsetsSetFormedFirstNNaturalNumbers
question_info.test_case_ids: 0 1 2 3 4 5 6
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js