title: Friends Pairing Problem 2
signature: function friends_pairing_problem_2(n)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(n, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(n), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver(24, 17492190577600);
      @printf("TEST-0...%s\n",result);
      
      result = driver(1, 1);
      @printf("TEST-1...%s\n",result);
      
      result = driver(29, 101990226254706560);
      @printf("TEST-2...%s\n",result);
      
      result = driver(3, 4);
      @printf("TEST-3...%s\n",result);
      
      result = driver(14, 2390480);
      @printf("TEST-4...%s\n",result);
      
  end
  
  main()
source_py: def friends_pairing_problem_2(n):
      (a, b, c) = (1, 2, 0)
      if (n <= 2):
          return n
      for i in range(3, (n + 1)):
          c = (b + ((i - 1) * a))
          a = b
          b = c
      return c
source_cpp: int friends_pairing_problem_2(int n) {
    int a = 1, b = 2, c = 0;
    if ( n <= 2 ) {
      return n;
    }
    for ( int i = 3;
    i <= n;
    i ++ ) {
      c = b + ( i - 1 ) * a;
      a = b;
      b = c;
    }
    return c;
  }