OFFSET
0,3
COMMENTS
It is possible to get to any positive integer.
A sequence worthy of consideration when teaching students subtraction.
For students, it is easier to ask them how many elements are needed in the sequence before they can get to n. This just adds three to all terms in the sequence except a(1):
4, 1, 5, 4, 7, 5, 6, 9, 8, 6, 7, 7, 8, 10, 9, 9, 9, 7, 8, 8, 9.
In this sequence, "difference of the last two" means absolute difference. - Michael S. Branicky, Apr 04 2021
LINKS
Hiroaki Yamanouchi, Table of n, a(n) for n = 0..100000
Gordon Hamilton, Fibonacci Killer Bunny Sequence (2012)
EXAMPLE
a(13) = 7 because starting at 1, 1, 1 it takes 7 steps to get to 13:
1, 1, 1, 3, 5, 9, 4, 5, 18, 13.
Here is a different way:
1, 1, 1, 0, 1, 1, 2, 4, 7, 13.
PROG
(Python)
def aupto(limit):
start, goals = (1, 1, 1), set(range(limit+1)) - {1}
steps, paths = {b: 0 for b in start}, {(0, ) + start}
iters = 1
while len(goals) > 0:
newpaths = []
while len(paths) > 0:
p = paths.pop() # each p stores last 3 elements
sum3, diff2 = sum(p[-3:]), abs(p[-2]-p[-1])
for newb in [sum3, diff2]:
if newb in goals:
steps[newb] = iters
goals.discard(newb)
newpaths.append( p[1:] + (newb, ) )
paths = newpaths
iters += 1
return [steps[b] for b in range(limit+1)]
print(aupto(81)) # Michael S. Branicky, Apr 04 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Gordon Hamilton, Mar 16 2015
EXTENSIONS
a(21)-a(81) from Hiroaki Yamanouchi, Mar 25 2015
STATUS
approved