Question: The formula for a combination of n objects in groups of r is n!/(n-r)!. A use for this formula would be to calculate how

The formula for a combination of n objects in groups of r is n!/(n-r)!.  A use for this formula would be to

The formula for a combination of n objects in groups of r is n!/(n-r)!. A use for this formula would be to calculate how many ways five people can win a race where there is a 1st, 2nd and 3rd place. This is the same as saying how many ways can you order five objects in only three positions. Using the above formula we would set n=5 and r-3 and calculate 5!/(5-3)! which simplifies to 5*4*3 or 60 possible ways. Write a function factorial() which accepts an integer as input and returns the factorial of the input. Write a program which uses factorial() to calculate the number of combinations of n objects taken r at a time Sample output Enter the number of objects: 2 Enter the group size: 2 The number of combinations of 2 objects in groups of 2 is 1 Enter the number of objects: 3 Enter the group size: 2 The number of combinations of 5 objects in groups of 3 is 3 Enter the number of objects: 5 Enter the group size: 3 The number of combinations of 5 objects in groups of 3 is 60

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Python program that calculates the number of combinations of n objects taken r at a time usi... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!