merely fiddlin

[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 here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

For any positive, base-10 integer N, define f(N) as the number of times you have to add up its digits until you get a one-digit number. Find the smallest whole number N such that f(N) = 4. Fiddler on the Proof

Although I first gave in to the R brute force attempt, it failed to return a value for N up to 10⁹, but the solution is obvious as f(N)=p iff F(s(N))=p-1. Since f(19)=2 and f(199)=3, a number N whose sum of digits is 199 is legit, for instance

f(99999999999999999999991)=4

where there are 22 9s. And although it gets a wee bit boring, here is the associated attempt by ChatGPT³

To leave a comment for the author, please follow the link and comment on their blog: R – Xi'an's Og.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)