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.

1.
Say one person infects N others.
2.
Say I is the part of the population that is immune.
(1 - I) is the part that has not yet gained immunity.
3.
(1 - I)N is the real number of people that are infected by one person.
4.
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
Examples:
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.