Question: C++/java program for calculating probability: ok so the problem is,we have a festival in which N artists are present.Each artist has his/her own masterpiece. in
C++/java program for calculating probability:
ok so the problem is,we have a festival in which N artists are present.Each artist has his/her own masterpiece.
in this festival,the artists decide to give their masterpieces to another artist in the festival,such that they are all going to
gather up all of their masterpieces and then, at the end of the festival, each artist will pick an art piece (completely at random)
the problem that might occur is that an artist might end up with his own artpiece.
write a C++ program that calculates the probability of the event that no artpiece will fall into the hands of its creator and the event
ends successfully?
the input to the program will be the number of artists in the festival
and the output will be the probability in fraction form such that the numerator is the number of successful and correct ways of distributing the artpieces amongst the artists and the denominator stands for every possible distribution i.e. N!
example #1:
input: 3
output: 1/3
example #2:
input: 6
output: 53/144
TIP:this problem has a recursive solution
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
