Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Heres a Python program that calculates the number of combinations of n objects taken r at a time usi...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started