There are **N** boys which are to be seated around a round table. The task is to find the number of ways in which **N** boys can sit around a round table such that two particular boys sit together.

**Examples: **

Input:N = 5

Output:48

2 boy can be arranged in 2! ways and other boys

can be arranged in (5 – 1)! (1 is subtracted because the

previously selected two boys will be considered as a single boy now)

So, total ways are 2! * 4! = 48.

Input:N = 9

Output:80640

**Approach:**

- First, 2 boys can be arranged in 2! ways.
- No. of ways to arrange remaining boys and the previous two boy pair is (n – 1)!.
- So,
**Total ways = 2! * (n – 1)!**.

Below is the implementation of the above approach:

## C++

`// C++ implementation of the approach ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to return the total count of ways ` `int` `Total_Ways(` `int` `n) ` `{ ` ` ` ` ` `// Find (n - 1) factorial ` ` ` `int` `fac = 1; ` ` ` `for` `(` `int` `i = 2; i <= n - 1; i++) { ` ` ` `fac = fac * i; ` ` ` `} ` ` ` ` ` `// Return (n - 1)! * 2! ` ` ` `return` `(fac * 2); ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `n = 5; ` ` ` ` ` `cout << Total_Ways(n); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation of the approach ` `import` `java.io.*; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to return the total count of ways ` `static` `int` `Total_Ways(` `int` `n) ` `{ ` ` ` ` ` `// Find (n - 1) factorial ` ` ` `int` `fac = ` `1` `; ` ` ` `for` `(` `int` `i = ` `2` `; i <= n - ` `1` `; i++) ` ` ` `{ ` ` ` `fac = fac * i; ` ` ` `} ` ` ` ` ` `// Return (n - 1)! * 2! ` ` ` `return` `(fac * ` `2` `); ` `} ` ` ` `// Driver code ` `public` `static` `void` `main (String[] args) ` `{ ` ` ` ` ` `int` `n = ` `5` `; ` ` ` ` ` `System.out.println (Total_Ways(n)); ` `} ` `} ` ` ` `// This code is contributed by Tushil. ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation of the approach ` ` ` `# Function to return the total count of ways ` `def` `Total_Ways(n) : ` ` ` ` ` `# Find (n - 1) factorial ` ` ` `fac ` `=` `1` `; ` ` ` `for` `i ` `in` `range` `(` `2` `, n) : ` ` ` `fac ` `=` `fac ` `*` `i; ` ` ` ` ` `# Return (n - 1)! * 2! ` ` ` `return` `(fac ` `*` `2` `); ` ` ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `n ` `=` `5` `; ` ` ` ` ` `print` `(Total_Ways(n)); ` ` ` `# This code is contributed by AnkitRai01 ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation of the approach ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to return the total count of ways ` `static` `int` `Total_Ways(` `int` `n) ` `{ ` ` ` ` ` `// Find (n - 1) factorial ` ` ` `int` `fac = 1; ` ` ` `for` `(` `int` `i = 2; i <= n - 1; i++) ` ` ` `{ ` ` ` `fac = fac * i; ` ` ` `} ` ` ` ` ` `// Return (n - 1)! * 2! ` ` ` `return` `(fac * 2); ` `} ` ` ` `// Driver code ` `static` `public` `void` `Main () ` `{ ` ` ` `int` `n = 5; ` ` ` ` ` `Console.Write(Total_Ways(n)); ` `} ` `} ` ` ` `// This code is contributed by ajit.. ` |

*chevron_right*

*filter_none*

**Output:**

48

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Seating arrangement of n boys and girls alternatively around a round table
- Possible arrangement of persons waiting to sit in a hall
- Minimum jumps required to make a group of persons sit together
- Permutations to arrange N persons around a circular table
- Arrangement of the characters of a word such that all vowels are at odd places
- Total number of ways to place X and Y at n places such that no two X are together
- Puzzle | Neighbors in a round table
- Number of ways to arrange a word such that no vowels occur together
- Number of ways to arrange a word such that all vowels occur together
- Maximum height of triangular arrangement of array values
- Arrangement of words without changing the relative position of vowel and consonants
- Distance Traveled by Two Trains together in the same Direction
- Probability of not getting two consecutive heads together in N tosses of coin
- Multiplication table till N rows where every Kth row is table of K upto Kth term
- Calculate Stirling numbers which represents the number of ways to arrange r objects around n different circles
- Length of rope tied around three equal circles touching each other
- Count n digit numbers not having a particular digit
- Count the number of occurrences of a particular digit in a number
- Total ways of selecting a group of X men from N men with or without including a particular man
- Check whether an array of strings can correspond to a particular number X

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.