title: Sum Series 23 45 67 89 Upto N Terms
signature: function sumSeries23456789UptoNTerms(n: number): number {
source_py: def sum_series_23_45_67_89_upto_n_terms(n):
      i = 1
      res = 0.0
      sign = True
      while (n > 0):
          n = (n - 1)
          if sign:
              sign = False
              res = (res + ((i + 1) / (i + 2)))
              i = (i + 2)
          else:
              sign = True
              res = (res - ((i + 1) / (i + 2)))
              i = (i + 2)
      return res
source_cpp: double sum_series_23_45_67_89_upto_n_terms(int n) {
    int i = 1;
    double res = 0.0;
    bool sign = true;
    while ( n > 0 ) {
      n --;
      if ( sign ) {
        sign = ! sign;
        res = res + ( double ) ++ i / ++ i;
      }
      else {
        sign = ! sign;
        res = res - ( double ) ++ i / ++ i;
      }
    }
    return res;
  }
question_info.test_list: [{"idx": 0, "outputs": 0.7803986631477524, "inputs": {"n": 49}}, {"idx": 1, "outputs": -0.16507936507936516, "inputs": {"n": 4}}, {"idx": 2, "outputs": -0.21050375120783382, "inputs": {"n": 60}}, {"idx": 3, "outputs": -0.21185466678122022, "inputs": {"n": 90}}, {"idx": 4, "outputs": -0.2120245854859959, "inputs": {"n": 96}}, {"idx": 5, "outputs": 0.7770671416747363, "inputs": {"n": 29}}, {"idx": 6, "outputs": -0.21172836828074082, "inputs": {"n": 86}}, {"idx": 7, "outputs": 0.780190394898247, "inputs": {"n": 47}}, {"idx": 8, "outputs": 0.7821931668684383, "inputs": {"n": 77}}, {"idx": 9, "outputs": 0.7825573460049735, "inputs": {"n": 87}}]
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(49, 0.7803986631477524);
    console.log(`TEST-0...${result}`);
  
    result = driver(4, -0.16507936507936516);
    console.log(`TEST-1...${result}`);
  
    result = driver(60, -0.21050375120783382);
    console.log(`TEST-2...${result}`);
  
    result = driver(90, -0.21185466678122022);
    console.log(`TEST-3...${result}`);
  
    result = driver(96, -0.2120245854859959);
    console.log(`TEST-4...${result}`);
  
    result = driver(29, 0.7770671416747363);
    console.log(`TEST-5...${result}`);
  
    result = driver(86, -0.21172836828074082);
    console.log(`TEST-6...${result}`);
  
    result = driver(47, 0.780190394898247);
    console.log(`TEST-7...${result}`);
  
    result = driver(77, 0.7821931668684383);
    console.log(`TEST-8...${result}`);
  
    result = driver(87, 0.7825573460049735);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: sumSeries23456789UptoNTerms
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