## Kempner Fi

**A** short code-golf challenge led me to learn about the Kempner series, which is the series made of the inverted integers, excluding all those containing the digit 9. Most surprisingly this exclusion is enough to see the series converging (close to 23). The explanation for this convergence is that, citing Wikipedia,

*“The number of n-digit positive integers that have no digit equal to ‘9’ is 8 × 9 ^{n−1}“*

and since the inverses of these *n*-digit positive integers are less than 10^{1−n} the series is bounded by 80. In simpler terms, it converges because the fraction of remaining terms in the series is geometrically decreasing as (9/10)^{1−n}. Unsurprisingly (?) the series is also atrociously slow to converge (for instance the first million terms sum up to 11) and there exist recurrence representations that speed up its computation. Here is the code-golf version

n=scan()+2

while(n<-n-1){

F=F+1/T

while(grepl(9,T<-T+1))0}

F

that led me to learn about the R function grepl. *(The explanation for the pun in the title is that Semper Fidelis is the motto of the corsair City of Saint-Malo or Sant-Maloù, Brittany.)*

January 20, 2021 at 8:12 am

[…] article was first published on R – Xi'an's Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) […]

January 20, 2021 at 4:14 am

[…] article was first published on R – Xi’an’s Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page […]

January 19, 2021 at 12:03 pm

[…] by data_admin [This article was first published on R – Xi’an’s Og, and kindly contributed to R-bloggers]. (You can report issue about the content on this page […]