title: Find N Th Element From Sterns Diatomic Series
signature: func findNThElementFromSternsDiatomicSeries(n int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(n int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(37, 11)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(24, 2)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(13, 5)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(56, 3)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(26, 5)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(67, 11)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(82, 11)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(60, 4)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(64, 1)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(65, 7)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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 ];
  }