Hi friends! I'm new to C++...in fact, this is my second programming class. I understand a bit of it, but not 100%. My assignment this week is to determine the number of potential team arrangements using the double type variable.
- If there are 18 people in your class and you want to divide the class into programming teams of 3 members, you can compute the number of different teams that can be arranged using this formula (n !⁄r !(n-r)!).
The coding that I have does not create the correct answer and I am also getting an error. Any help is appreciated!!
http://www.cplusplus.com/forum/beginner/92924/
OP is copy-paste spam of a five year old post. Very strange. They went through the trouble of creating a burner account and using the code tags, marking the post as solved, so they actually know how to use this site already. Would have been less effort just to do the assignment.
Is the goal to use this as a add-spam account later on?
@j3n1096,
You are falling into the trap of seeing a formula involving factorials for convenience ... and automatically assuming that you need to code it using factorials.
Factorials rapidly overflow integers, whilst using doubles leads to unnecessary floating-point rounding error. And Sterling’s formula is only an asymptotic approximation (for large n). It would be hopeless for 3 factorial.
18C3 is just (18*17*16)/(1*2*3) and that is easily computable in integers.
18!/15! cancels down to 18*17*16 - it is completely unnecessary to work out 18! and 15! separately.