title: Find N Th Element From Sterns Diatomic Series
signature: find_n_th_element_from_sterns_diatomic_series <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          37L, 
          11L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          24L, 
          2L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          13L, 
          5L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          56L, 
          3L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          26L, 
          5L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          67L, 
          11L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          82L, 
          11L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          60L, 
          4L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          64L, 
          1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          65L, 
          7L
      )))
  
  }
  
  main()
source_py: def find_n_th_element_from_sterns_diatomic_series(n):
      DP = ([0] * (n + 1))
      DP[0] = 0
      DP[1] = 1
      for i in range(2, (n + 1)):
          if (int((i % 2)) == 0):
              DP[i] = DP[int((i / 2))]
          else:
              DP[i] = (DP[int(((i - 1) / 2))] + DP[int(((i + 1) / 2))])
      return DP[n]
source_cpp: int find_n_th_element_from_sterns_diatomic_series(int n) {
    int DP [ n + 1 ];
    DP [ 0 ] = 0;
    DP [ 1 ] = 1;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      if ( i % 2 == 0 ) DP [ i ] = DP [ i / 2 ];
      else DP [ i ] = DP [ ( i - 1 ) / 2 ] + DP [ ( i + 1 ) / 2 ];
    }
    return DP [ n ];
  }