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”).

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

%I #27 Dec 20 2019 23:38:45

%S 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,

%T 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,

%U 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

%N 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.

%H S. Brunner, <a href="/A328059/b328059.txt">Table of n, a(n) for n = 0..10000</a>

%H S. Brunner, <a href="https://pastebin.com/BDzgnvhP">Link for python program which shows calculation steps for each number</a>

%H S. Brunner, <a href="https://pastebin.com/T3umyseT">List for n = 0..5600 with calculation steps for each n</a>

%e a(10)=2 because you need 2 calculation steps to get to 10.

%e The numbers for the first calculation are: a(n-2)=a(8)=2, a(n-1)=a(9)=3.

%e We need to add these 2 numbers: 2+3=5 (1st step).

%e 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).

%e 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.

%e The numbers we need to use {a(n-5) to a(n)} are: 5,3,5,4,3,5.

%e 1. 5+3=8 | 2. 8*5=40 | 3. 40-4=36 | 4. 36+3=39 | 5. 39-5=34.

%o (Python)

%o def A(z):

%o a=[0,1,1]

%o n=3

%o an=2

%o while n<=z:

%o list1=[a[n-an]]

%o nn=an-2

%o while nn>0:

%o l=len(list1)

%o i=0

%o while i<l:

%o v=list1[0]

%o list1.remove(v)

%o list1.append(v+a[n-nn-1])

%o if v-n<300:

%o list1.append(v*a[n-nn-1])

%o list1.append(v-a[n-nn-1])

%o i=i+1

%o nn=nn-1

%o c=list1.count(n-an-a[n-1])+list1.count(n/an-a[n-1])+list1.count(n+an-a[n-1])

%o c=c+list1.count((n-an)/a[n-1])+list1.count((n/an)/a[n-1])+list1.count((n+an)/a[n-1])

%o c=c+list1.count(n-an+a[n-1])+list1.count(n/an+a[n-1])+list1.count(n+an+a[n-1])

%o if c==0:

%o an=an+1

%o else:

%o a.append(an)

%o print(n,an)

%o n=n+1

%o an=2

%o return a

%K nonn

%O 0,4

%A _S. Brunner_, Oct 03 2019