title: Sum Series 23 45 67 89 Upto N Terms
signature: pub fn sum_series_23_45_67_89_upto_n_terms(n: i32) -> f64 {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: f64, expected: f64)->bool{
  return (actual - expected).abs() < 1e-09
  }
  pub fn driver(n: i32, expected: f64)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(n), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        49, 
        0.7803986631477524
      ));
      
      println!("TEST-1...{}", driver(
        4, 
        -0.16507936507936516
      ));
      
      println!("TEST-2...{}", driver(
        60, 
        -0.21050375120783382
      ));
      
      println!("TEST-3...{}", driver(
        90, 
        -0.21185466678122022
      ));
      
      println!("TEST-4...{}", driver(
        96, 
        -0.2120245854859959
      ));
      
      println!("TEST-5...{}", driver(
        29, 
        0.7770671416747363
      ));
      
      println!("TEST-6...{}", driver(
        86, 
        -0.21172836828074082
      ));
      
      println!("TEST-7...{}", driver(
        47, 
        0.780190394898247
      ));
      
      println!("TEST-8...{}", driver(
        77, 
        0.7821931668684383
      ));
      
      println!("TEST-9...{}", driver(
        87, 
        0.7825573460049735
      ));
      
  }
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;
  }