title: Sum Series 23 45 67 89 Upto N Terms
signature: function sum_series_23_45_67_89_upto_n_terms(n)
test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return math.abs(actual - expected) < 1e-09
  end
  
  function driver(n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(49, 0.7803986631477524)
      print(string.format("TEST-0...%s",result))
  
      result = driver(4, -0.16507936507936516)
      print(string.format("TEST-1...%s",result))
  
      result = driver(60, -0.21050375120783382)
      print(string.format("TEST-2...%s",result))
  
      result = driver(90, -0.21185466678122022)
      print(string.format("TEST-3...%s",result))
  
      result = driver(96, -0.2120245854859959)
      print(string.format("TEST-4...%s",result))
  
      result = driver(29, 0.7770671416747363)
      print(string.format("TEST-5...%s",result))
  
      result = driver(86, -0.21172836828074082)
      print(string.format("TEST-6...%s",result))
  
      result = driver(47, 0.780190394898247)
      print(string.format("TEST-7...%s",result))
  
      result = driver(77, 0.7821931668684383)
      print(string.format("TEST-8...%s",result))
  
      result = driver(87, 0.7825573460049735)
      print(string.format("TEST-9...%s",result))
  
  end
  
  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;
  }