In a small town the population is p0 = 1000
at the beginning of a year. The population regularly increases by 2 percent per year
and moreover 50 new inhabitants per year
come to live in the town. How many years does the town need to see its population greater or equal to p = 1200
inhabitants?
需要多少年 p0 才能超过 p, 每年人口成长率为 percent, 每年移入人口数为 aug
At the end of the first year there will be:
1000 + 1000 * 0.02 + 50 => 1070 inhabitants
At the end of the 2nd year there will be:
1070 + 1070 * 0.02 + 50 => 1141 inhabitants (number of inhabitants is an integer)
At the end of the 3rd year there will be:
1141 + 1141 * 0.02 + 50 => 1213
It will need 3 entire years.
(ns arge.core)
(defn nb-year [p0 percent aug p]
(let [percent (inc (/ percent 100))]
(count (take-while #(< % p) (iterate #(long (+ aug (* % percent))) p0)))))
<<: Laravel 实战经验分享 - Day28 API 文件的写法
>>: Generate CSRF PoC 伪造跨站请求漏洞利用产生
Line上可用的emojis有两种一种是Unicode emojis,另一种是LINE emojis...
当周进度 NET101 从拉面店的贩卖机理解什麽是 API 从传纸条轻松学习基本网路概念 Reque...
8.3 找出双连通元件 图 G 上面的双连通元件 (Biconnected Component) 是...
连线设定其实也没什麽好介绍的,改 env 这种事 sail 已经弄好了。 即便现在,用 compos...
我们在这里用到了文字编辑器, 我们使用的是CKEditor, 可以到 这边 下载 也可以参照 官方文...