simple math of epidemics

An epidemic starts with one deceased person that infects others, etcetera...
The decease spreads among the population.
Recovered persons are immune so from a certain moment the decease will disappear
because too many people have obtained immunity.
The virus dies because of the lack of hosts.

However: at which moment will this situation occur?
Here is a simple formula.

Say one person infects N others.
Say I is the part of the population that is immune.
(1 - I) is the part that has not yet gained immunity.
(1 - I)N is the real number of people that are infected by one person.
The decease will no longer spread if :
    (1 - I)N < 1
    N - IN < 1
    IN > N - 1
    I > (N - 1)/N
    I > 1 - 1/N
If one person infects 3 others than is needed: I > 1 - 1/3 = 67%
If 67% of the population is immune, the decease will stop.

Measles is a very contagious desease.
If a child infects 20 others, the percentage of children that requires vaccination is
1 - 1/20 = 95% to avoid spreading.