title: Sum Series 23 45 67 89 Upto N Terms
signature: sum_series_23_45_67_89_upto_n_terms <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      abs(actual - expected) < 1e-09
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          49L, 
          0.7803986631477524
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          4L, 
          -0.16507936507936516
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          60L, 
          -0.21050375120783382
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          90L, 
          -0.21185466678122022
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          96L, 
          -0.2120245854859959
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          29L, 
          0.7770671416747363
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          86L, 
          -0.21172836828074082
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          47L, 
          0.780190394898247
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          77L, 
          0.7821931668684383
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          87L, 
          0.7825573460049735
      )))
  
  }
  
  main()
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;
  }