[seqfan] Haverbeke's 1 plus 5 or times 3 problem
Alonso Del Arte
alonso.delarte at gmail.com
Fri Jun 5 03:56:02 CEST 2020
To illustrate recursive functions in *Eloquent JavaScript*, Marijn
Haverbeke posits the following problem: start from 1, then either add 5 or
multiply by 3. Repeat one or the other or alternate in whatever pattern you
want. Some numbers, like 13, can be reached in at least one way. Others,
like 15, are unreachable. Write a JavaScript function to find a solution
for a given number; it doesn't have to be the "best" solution, it simply
has to be *a* solution, if it exists for the particular number.
Maybe Haverbeke's the first to connect this mathematical problem to
JavaScript, but I doubt he's the one who first formulated it. Although it's
also possible that he remembered a similar problem and intentionally or
unintentionally changed it to suit his purpose. Though I doubt anyone
before me has explored the variant starting with −1, which I'm not ready to
say anything more about at this time.
As usual for problems of this sort, the first reference to consult is the
OEIS. My searches got lots of results, but in this instance I suspect they
were often irrelevant matches, and a demonstration of the law of small
numbers.
Haverbeke bibliographic citation and link to Scastie snippet currently at
https://oeis.org/draft/A335365
My question to y'all: have you ever heard of this problem before, or a
similar problem?
Al
--
Alonso del Arte
Author at SmashWords.com
<https://www.smashwords.com/profile/view/AlonsoDelarte>
Musician at ReverbNation.com <http://www.reverbnation.com/alonsodelarte>
More information about the SeqFan
mailing list