probability application 1) A disease has hit a city. The percentage of the population infected $t$ days     after the disease arrives is approximated by $$p(t) = 12te^{\frac{-t}{7}} \qquad \mbox{for} \qquad0\leq t \leq 35.$$ 
After how many days is the percentage of infected people a maximum? What is the maximum percent of the population infected?
The maximum percent of  the population  infected    is  ______  %
2) A container contains 12 diesel engines.  The company chooses 5 engines at random and will not ship the container if any of the engines chosen are defective.  Find the probability that a container will be shipped even though it contains 2 defectives if the sample size is 5.
For the first problem, the number of days at which the percentage is at maximum is 7. Clearly, if I substitute this to $p(t)$ I will get the maximum percentage. My problem is how did they get the answer of 7 days? How do I deal with this kind of problem? Is there a specific formula? I'm trying to figure it out but can't.
Also for the second problem I made use of the hypergeometric formula that is $$p(x) = \frac{\left[C(k,x) \cdot C(N-k, n-x)\right]}{C(N,n)}$$ where $N$ is the size of population, $k$ is the number of successes in the population, $x$ is the number of successes in the sample and $n$ is the sample size. I used this and I got a different answer. The answer should have been 0.318 but I got a different one. Please help. 
 A: Mode of gamma distribution. For (1), recognize that $p(x)$ is the PDF of a gamma distribution with shape parameter 2 and scale parameter 7. Look at the Wikipedia article. Its mode is $x = (2-1)7 = 7.$ (The bound 35 is so far out as to be irrelevant to the discussion.)
Application of hypergeometric to acceptance sampling. For (2), I used the hypergeometric PDF programmed into R as follows:
 dhyper(0, 2, 10, 5)
 ## 0.3181818

So it seems you have made a mistake. 
Hint: What is ${10 \choose 5}$
and what is ${12 \choose 5}?$
A: The gradient (or "slope") at a local maximum, minimum, or point of inflection, will equal zero.
We have $p(t) = 12 t e^{-t/7}$ , so then by differentiation (using the chain rule): $\frac{\mathrm d p(t)}{\mathrm d t} = 12 e^{-t/7} - \dfrac{12 t}{7} e^{-t/7}$.
Solving for $t$ when $\frac{\mathrm d p(t)}{\mathrm d t}=0$ gives us $t=7$.   This exists within our interval $0\leq t \leq 35$, thus all we need do is check is that it is indeed a maximum.
$$p(7) \approx 30.9 \\ p(6) \approx 30.6 \\ p(8) \approx 30.62$$

For the second problem the container will be shipped if the two defective containers are among the seven not inspected.   By counting distinct ways to select places for defectives, the probability of this is: ${^{7}{\rm C}_{2}}\big/ {^{12}{\rm C}_{2}} = \frac{7\times 6}{12\times 11}$
Using the hypergeometric formula, this is $p(0) = \dfrac{{^{5}{\rm C}_{0}}\;{^{12-5}{\rm C}_{2-0}}}{ {^{12}{\rm C}_{2}}}$
