Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • DSA
  • Practice Mathematical Algorithm
  • Mathematical Algorithms
  • Pythagorean Triplet
  • Fibonacci Number
  • Euclidean Algorithm
  • LCM of Array
  • GCD of Array
  • Binomial Coefficient
  • Catalan Numbers
  • Sieve of Eratosthenes
  • Euler Totient Function
  • Modular Exponentiation
  • Modular Multiplicative Inverse
  • Stein's Algorithm
  • Juggler Sequence
  • Chinese Remainder Theorem
  • Quiz on Fibonacci Numbers
Open In App
Next Article:
Permutations to arrange N persons around a circular table
Next article icon

Permutations to arrange N persons around a circular table

Last Updated : 31 Aug, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Given N, the number of persons. The task is to arrange N person around a circular table.
Examples: 
 

Input: N = 4 Output: 6  Input: N = 5 Output: 24


 


Approach: It is the concept of Circular permutation i.e. there is no specific starting point in the arrangement, any element can be considered as the start of the arrangement. 
For N = 4, Arrangements will be:
 


Below is the formula to find Circular permutations: 
 

Circular Permutations = (N - 1)!


Below is the implementation of above idea: 
 

C++
// C++ code to demonstrate Circular Permutation #include <bits/stdc++.h> using namespace std;  // Function to find no. of permutations int Circular(int n) {      int Result = 1;      while (n > 0) {         Result = Result * n;         n--;     }      return Result; }  // Driver Code int main() {     int n = 4;      cout << Circular(n - 1); } 
Java
// Java code to demonstrate  // Circular Permutation  import java.io.*;  class GFG { // Function to find no.  // of permutations  static int Circular(int n)  {       int Result = 1;       while (n > 0)      {          Result = Result * n;          n--;      }       return Result;  }   // Driver Code public static void main(String[] args) {     int n = 4;          System.out.println(Circular(n - 1)); } }  // This code is contributed  // by Naman_Garg 
Python 3
# Python 3 Program to demonstrate Circular Permutation    # Function to find no. of permutations def Circular(n) :     Result = 1      while n > 0 :         Result = Result * n         n -= 1      return Result      # Driver Code if __name__ == "__main__" :     n = 4      # function calling     print(Circular(n-1))  # This code is contributed by ANKITRAI1 
C#
// C# code to demonstrate  // Circular Permutation  using System;                       public class GFG {  // Function to find no.  // of permutations  static int Circular(int n)  {        int Result = 1;        while (n > 0)      {          Result = Result * n;          n--;      }        return Result;  }    // Driver Code public static void Main() {     int n = 4;           Console.Write(Circular(n - 1)); } }   /* This Java code is contributed by 29AjayKumar*/ 
PHP
<?php // PHP code to demonstrate Circular Permutation  // Function to find no. of permutations function Circular($n) {     $Result = 1;      while ($n > 0)      {         $Result = $Result * $n;         $n--;     }      return $Result; }  // Driver Code $n = 4;  echo Circular($n - 1);  // This code is contributed by mits ?> 
JavaScript
<script> // javascript code to demonstrate  // Circular Permutation       // Function to find no.     // of permutations     function Circular(n)      {         var Result = 1;         while (n > 0)          {             Result = Result * n;             n--;         }          return Result;     }      // Driver Code     var n = 4;     document.write(Circular(n - 1));  // This code is contributed by Rajput-Ji  </script> 

Output: 
6

 

Time Complexity: O(N) where N is the number of persons.
Auxiliary Space: O(1), since no extra space has been taken.


Next Article
Permutations to arrange N persons around a circular table

N

Naman_Garg
Improve
Article Tags :
  • Mathematical
  • C++ Programs
  • DSA
  • permutation
  • math
  • Permutation and Combination
Practice Tags :
  • Mathematical
  • permutation

Similar Reads

    Find the total guests that are present at the party
    A person hosts a party and invites N guests to it. However, each guest has a condition, that each guest 'Gi' only stays at the party if there are at least 'Pi' people already at the party, otherwise leaves. The total number of guests N and the number of people each guest needs 'Pi' are given as inpu
    7 min read
    Count ways to remove objects such that exactly M equidistant objects remain
    Given an integer N, representing objects placed adjacent to each other, the task is to count the number of ways to remove objects such that after their removal, exactly M objects are left and the distance between each adjacent object is equal. Examples: Input: N = 5, M = 3Output: 4Explanation:Let th
    6 min read
    Josephus Problem | Set 3 (using STL)
    Given N persons are standing in a circle and an integer K. If initially starting from the first position, the Kth alive person clockwise from the current position is killed, and then the current position is shifted to the position of (K+1)th alive person and the same step is performed until only one
    12 min read
    Count arrangements of N people around circular table such that K people always sit together
    Given integers N and K, the task is to find the number of possible arrangements of N people around a circular table such that K people always sit together. Note: As the answer can be very large return it modulo 109 + 7 Examples: Input: N = 4, K = 3Output: 6Explanation: If 3 people always sit togethe
    5 min read
    Count non-adjacent subsets from numbers arranged in Circular fashion
    Given that N people are sitting in a circular queue numbered from 1 to N, the task is to count the number of ways to select a subset of them such that no two consecutive are sitting together. The answer could be large, so compute the answer modulo 109 + 7. Note that an empty subset is also a valid s
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences