Log in to save your progress.
<< Back to problems
Note! The window is too narrow to use Pythonlab.dev. Use a device with a keyboard!

Probability of n events

Prerequisites: Basic course part I

Say there is a 1% chance of winning on a lottery ticket. It is then easy to think that if we buy 100 tickets, we will almost certainly win on some ticket. Or that we buy 1000 tickets and the probability of winning on each ticket is 1/1000 = 0.001 (0.1%). Then it's almost certain we win, right? Or what is the probability really?

Your task is to calculate the probability of winning if you buy n lottery tickets and the probability of winning on one ticket is 1/n.

The only input from the user is the integer n, and the only output is the probability of at least one win. Round the answer to four decimal places using round(p,4).

Example input 1

2

Example output 1

0.75

Example input 2

3

Example output 2

0.7037

Example input 3

4

Example output 3

0.6836

PS. If you have learned about the number e, calculate 1 - 1/e and compare with the result for a large n in this task.

Login to save your progress and your code.

Create

Write your code here.

-- Output from your program will be here --