# Python Program for Permutations In Which N People Can Occupy R Seats In A Classroom

## Permutations In Which N People Can Occupy R Seats In A Classroom

In this python program, we will be defining the number of ways in which N number of students can occupy R number of seats. Take an example Ten friends enter the classroom late and all the seats are occupied by topers of the college and now only Six seats are available so in how many ways are those Ten friends will occupy Six seats although 4 students have to leave the classroom. We will use math library for factorial function in building of this program. ## Algorithm

• Step 1:- Start.
• Step 2:- Take user inputs for N and R.
• Step 3:- Calculate factorial for number of students/N so we can calculate permutation.
• Step 4:- Calculate factorial for N-R value so we can calculate permutation.
• Step 5:- Divide N with N-R to calculate the permutation.
• Step 6:- Print the number of ways.
• Step 7:- End. ## Python program to calculate number of ways in which N people can occupy R seats

```#import math lib
import math
#take user inputs
N = int(input('Enter the number of students :'))
R = int(input('Enter the number of seats :'))
#factorial by using factorial() function
nume = math.factorial(N)
deno = math.factorial(N-R)
#permutation = n! / (n-r)!
no_of_ways = nume//deno
#print total no of ways
print('Total number of ways are :' + str(no_of_ways))```
```Output:
Enter the number of students :10
Enter the number of seats :6
Total number of ways are :151200```