title: Friends Pairing Problem 2
signature: pub fn friends_pairing_problem_2(n: i32) -> i64 {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: i64, expected: i64)->bool{
  return actual==expected
  }
  pub fn driver(n: i32, expected: i64)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(n), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        24, 
        17492190577600
      ));
      
      println!("TEST-1...{}", driver(
        1, 
        1
      ));
      
      println!("TEST-2...{}", driver(
        29, 
        101990226254706560
      ));
      
      println!("TEST-3...{}", driver(
        3, 
        4
      ));
      
      println!("TEST-4...{}", driver(
        14, 
        2390480
      ));
      
  }
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;
  }