In the textbook, there is a program that prints the odds of participating in a “Choose k from n” lottery. In this exercise, read n and print the odds for all k from 1 to n. Print them as percentages, with 3 digits after the decimal separator. Above each value, print k. Use the smallest possible value for the column width (i.e., make 100.000%
fit).
Use long
values in the calculation. With int
, the calculation will overflow for moderate values of n and k.