login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A328059
a(n) is the number of additions, subtractions and/or multiplications needed to calculate n using numbers a(n-a(n)) to a(n) in order and in single step calculations.
1
0, 1, 1, 2, 2, 4, 2, 3, 2, 3, 2, 3, 2, 3, 4, 4, 2, 3, 3, 4, 4, 4, 6, 5, 5, 5, 4, 6, 4, 5, 3, 5, 4, 3, 5, 5, 4, 3, 4, 5, 2, 4, 3, 6, 4, 5, 5, 7, 4, 5, 5, 6, 7, 5, 3, 5, 4, 3, 6, 5, 2, 7, 6, 7, 5, 5, 4, 6, 6, 7, 5, 6, 6, 6, 8, 5, 7, 7, 6, 5, 5, 7, 5, 7, 3, 4, 5, 6, 5, 6, 6, 7, 7, 7, 4, 8, 6, 7, 7, 6, 5
OFFSET
0,4
EXAMPLE
a(10)=2 because you need 2 calculation steps to get to 10.
The numbers for the first calculation are: a(n-2)=a(8)=2, a(n-1)=a(9)=3.
We need to add these 2 numbers: 2+3=5 (1st step).
To get 10 as result we need to multiply 5 from step 1 with a(n) itself, so we get 5*2=10 (2nd step).
For n=34 we need 5 calculation steps, because there is no solution with 4 or fewer steps, but we pretend we tested these cases before.
The numbers we need to use {a(n-5) to a(n)} are: 5,3,5,4,3,5.
1. 5+3=8 | 2. 8*5=40 | 3. 40-4=36 | 4. 36+3=39 | 5. 39-5=34.
PROG
(Python)
def A(z):
a=[0, 1, 1]
n=3
an=2
while n<=z:
list1=[a[n-an]]
nn=an-2
while nn>0:
l=len(list1)
i=0
while i<l:
v=list1[0]
list1.remove(v)
list1.append(v+a[n-nn-1])
if v-n<300:
list1.append(v*a[n-nn-1])
list1.append(v-a[n-nn-1])
i=i+1
nn=nn-1
c=list1.count(n-an-a[n-1])+list1.count(n/an-a[n-1])+list1.count(n+an-a[n-1])
c=c+list1.count((n-an)/a[n-1])+list1.count((n/an)/a[n-1])+list1.count((n+an)/a[n-1])
c=c+list1.count(n-an+a[n-1])+list1.count(n/an+a[n-1])+list1.count(n+an+a[n-1])
if c==0:
an=an+1
else:
a.append(an)
print(n, an)
n=n+1
an=2
return a
CROSSREFS
Sequence in context: A131287 A102640 A332581 * A123674 A363219 A371531
KEYWORD
nonn
AUTHOR
S. Brunner, Oct 03 2019
STATUS
approved