Question: Program needs to be written recursively and in Java A combination is a way of selecting several items out of a group of items where

 Program needs to be written recursively and in Java A combination

Program needs to be written recursively and in Java

A combination is a way of selecting several items out of a group of items where order does not matter. For example, say that you have five colors, Red, Orange, Yellow, Green, and Blue and you want to select two of them. There are 10 ways this can be done: (R, 0) (R, Y) (R, G) (0, Y) (0, G) (Y, G) (R, B) (0, B) (Y, B) (G, B) Often you want to know how many combinations are possible when N things are selected from M items. In the above example, N is 2, and M is 5. A formula for this is; Comb( M, N ) = M! / (N!(M-N)!) Unfortunately, the factorial function quickly gets very big. If you try to use this formula directly, you will likely discover that M! "blows up" even when the final value of Comb( M, N ) is within the range of data type int. For example, 15! = 1 307 674 368 000 well beyond the range of int. However, Comb( 15, 5 ) = 3003 which easily fits into an int. To use the formula, you need to be fairly clever to get common factors in the numerator and denominator to cancel. A recursive formula is: if M

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!