title: Double Factorial 1
signature: function doubleFactorial1(n: number): number {
source_py: def double_factorial_1(n):
      res = 1
      for i in range(n, (- 1), (- 2)):
          if ((i == 0) or (i == 1)):
              return res
          else:
              res *= i
source_cpp: unsigned int double_factorial_1(unsigned int n) {
    int res = 1;
    for ( int i = n;
    i >= 0;
    i = i - 2 ) {
      if ( i == 0 || i == 1 ) return res;
      else res *= i;
    }
  }
question_info.test_list: [{"idx": 0, "outputs": 1961990553600, "inputs": {"n": 24}}, {"idx": 1, "outputs": 3, "inputs": {"n": 3}}, {"idx": 2, "outputs": 81749606400, "inputs": {"n": 22}}, {"idx": 3, "outputs": 2, "inputs": {"n": 2}}, {"idx": 4, "outputs": 42849873690624000, "inputs": {"n": 30}}, {"idx": 5, "outputs": 2, "inputs": {"n": 2}}]
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 convertToString(actual) === convertToString(expected);
  }
  
  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(24, 1961990553600);
    console.log(`TEST-0...${result}`);
  
    result = driver(3, 3);
    console.log(`TEST-1...${result}`);
  
    result = driver(22, 81749606400);
    console.log(`TEST-2...${result}`);
  
    result = driver(2, 2);
    console.log(`TEST-3...${result}`);
  
    result = driver(30, 42849873690624000);
    console.log(`TEST-4...${result}`);
  
    result = driver(2, 2);
    console.log(`TEST-5...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: doubleFactorial1
question_info.test_case_ids: 0 1 2 3 4 5
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js