login
a(n) is the maximal number of a's that can be produced in a blank document with n "keystrokes".
36

%I #70 Jun 09 2022 14:42:51

%S 1,2,3,4,5,6,7,9,12,16,20,25,30,36,48,64,80,100,125,150,192,256,320,

%T 400,500,625,768,1024,1280,1600,2000,2500,3125,4096,5120,6400,8000,

%U 10000,12500,16384,20480,25600,32000,40000,50000,65536,81920,102400,128000,160000,200000,262144,327680

%N a(n) is the maximal number of a's that can be produced in a blank document with n "keystrokes".

%C A "keystroke" means one of the following:

%C a (i.e., hit the letter "a" on the keyboard)

%C Ctrl-a ("select all")

%C Ctrl-c (copy selected text to clipboard)

%C Ctrl-v (paste from clipboard to cursor location)

%C Alternatively, a(n-2) = maximal value of Product (k_i-2) for any way of writing n = Sum k_i

%C 1. Note that the copy command does not deselect the text.

%C 2. This sequence is a "paradigm-shift" sequence with procedure length p =2 (in the sense of A193455).

%C 3. The optimal number of pastes per copy, as measured by the geometric growth rate (p+z root of z), is z = 4. [Non-integer maximum between 4 and 5.]

%C 4. The function a(n) = maximum value of the product of the terms k_i, where Sum (k_i) = n + 2 - 2*i_max.

%C 5. All solutions will be of the form a(n) = m^b * (m+1)^d.

%H Vincenzo Librandi, <a href="/A193286/b193286.txt">Table of n, a(n) for n = 1..1000</a>

%H John Derbyshire, <a href="http://www.johnderbyshire.com/Opinions/Diaries/Puzzles/2011-06.html">Solutions to puzzles in my National Review Online Diary: June 2011</a>

%H John Derbyshire, <a href="/A193286/a193286.pdf">Solutions to puzzles in my National Review Online Diary: June 2011</a> [Cached copy, pdf version only, with permission]

%H Jonathan T. Rowell, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL18/Rowell/rowell3.html">Solution Sequences for the Keyboard Problem and its Generalizations</a>, Journal of Integer Sequences, Vol. 18 (2015), Article 15.10.7.

%F a(n) = 4*a(n-6) for n >= 34. [corrected by _Georg Fischer_, Jun 09 2022]

%F a(n) = a(8;9;15;21;27) = 9; 12; 48; 192; 768 - corresponding to [C=2;2;3;4;5 below].

%F a(n=1:27) = Q^(C-R) * (Q+1)^R where C = floor((n+2)/6 [minimum value 1], R = n+2 mod C, and Q = floor((n+2)/c)-2.

%F a(n>=28) = 4^(C-R) * 5^R, where C = floor(n+2/6), R = (n+2) mod 6.

%e For n=25, C=floor(27/6) = 4, R=(27 mod 4)= 3, and Q=floor(27/4)-2=4; therefore, a(25) = 4^(4-3)*5^(3)=4*5^3=500.

%e For n=9, we use the general solution, but with C=2 (rather than C=1). R=(11 mod 2)=1, Q=3, and a(9)=3^(2-1)*4^1 = 12.

%t a[n_ /; 1 <= n <= 7] := n; a[8] = 9; a[n_ /; 9 <= n <= 27] := (c = Max[1, Floor[(n+3)/6]]; r = Mod[n+2, c]; q = Floor[(n+2)/c]-2;q^(c-r)*(q+1)^r);a[n_ /; n >= 28] := ({q, r} = QuotientRemainder[n+2, 6]; 4^(q-r)*5^r);Table[a[n], {n, 1, 60}] (* _Jean-François Alcover_, May 28 2015 *)

%o (Haskell)

%o -- See Theorem 5 in John Derbyshire link.

%o a193286 n = p n [] where

%o p 0 ks = product ks

%o p n [] = p (n-1) [1]

%o p n (k:ks)

%o | n < 0 = 0

%o | otherwise = max (p (n-1) ((k+1):ks)) (p (n-3) (1:k:ks))

%o -- _Reinhard Zumkeller_, Jul 22 2011, Jul 21 2011

%o (Python)

%o def a(n):

%o if n<8: return n

%o elif n==8: return 9

%o elif n>8 and n<=27:

%o c=max(1, ((n + 3)//6))

%o r=(n + 2)%c

%o q=((n + 2)//c) - 2

%o return q**(c - r)*(q + 1)**r

%o else:

%o q=((n + 2)//6)

%o r=(n + 2)%6

%o return 4**(q - r)*5**r

%o print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, Jun 27 2017, after Mathematica code

%Y See A178715 for another version. Cf. A000792.

%Y A000792, A178715, A193286, A193455, A193456, and A193457 are paradigm shift sequences of procedure lengths p=0,1,...,5, respectively.

%K nonn,nice

%O 1,2

%A _N. J. A. Sloane_, Jul 20 2011

%E Additional comment and formula from _David Applegate_, Jul 21 2011

%E More terms from _Reinhard Zumkeller_, Jul 22 2011, Jul 21 2011

%E Additional comments, formulas, examples and CrossRefs from _Jonathan T. Rowell_, Jul 30 2011