title: Find N Th Element From Sterns Diatomic Series
signature: findNThElementFromSternsDiatomicSeries(n) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          37, 
          11)
      }");
  
      print("TEST-1...${driver(
          24, 
          2)
      }");
  
      print("TEST-2...${driver(
          13, 
          5)
      }");
  
      print("TEST-3...${driver(
          56, 
          3)
      }");
  
      print("TEST-4...${driver(
          26, 
          5)
      }");
  
      print("TEST-5...${driver(
          67, 
          11)
      }");
  
      print("TEST-6...${driver(
          82, 
          11)
      }");
  
      print("TEST-7...${driver(
          60, 
          4)
      }");
  
      print("TEST-8...${driver(
          64, 
          1)
      }");
  
      print("TEST-9...${driver(
          65, 
          7)
      }");
  
      return 0;
  }
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 ];
  }