title: Dynamic Programming Set 36 Cut A Rope To Maximize Product 1
signature: dynamic_programming_set_36_cut_a_rope_to_maximize_product_1 <- 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(
          62L, 
          6973568802L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          53L, 
          258280326L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          8L, 
          18L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          6L, 
          9L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          35L, 
          354294L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          35L, 
          354294L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          46L, 
          19131876L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          74L, 
          564859072962L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          69L, 
          94143178827L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          3L, 
          2L
      )))
  
  }
  
  main()
source_py: def dynamic_programming_set_36_cut_a_rope_to_maximize_product_1(n):
      if ((n == 2) or (n == 3)):
          return (n - 1)
      res = 1
      while (n > 4):
          n -= 3
          res *= 3
      return (n * res)
source_cpp: int dynamic_programming_set_36_cut_a_rope_to_maximize_product_1(int n) {
    if ( n == 2 || n == 3 ) return ( n - 1 );
    int res = 1;
    while ( n > 4 ) {
      n -= 3;
      res *= 3;
    }
    return ( n * res );
  }