>>319
1から虱潰し探すより、fは増加関数だからニュートンラフソンで計算した方が計算時間が短縮できる。

uniroot(function(n,u=2021) fn(n)-2021, c(1,1e5))$root
fn(17578)
fn(17579)

> uniroot(function(n,u=2021) fn(n)-2021, c(1,1e5))$root
[1] 17578.55
> fn(17578)
[1] 2020
> fn(17579)
[1] 2021