OFFSET
1,2
COMMENTS
A "keystroke" means one of the following:
a (i.e., hit the letter "a" on the keyboard)
Ctrl-a ("select all")
Ctrl-c (copy selected text to clipboard)
Ctrl-v (paste from clipboard to cursor location)
Alternatively, a(n-2) = maximal value of Product (k_i-2) for any way of writing n = Sum k_i
1. Note that the copy command does not deselect the text.
2. This sequence is a "paradigm-shift" sequence with procedure length p =2 (in the sense of A193455).
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.]
4. The function a(n) = maximum value of the product of the terms k_i, where Sum (k_i) = n + 2 - 2*i_max.
5. All solutions will be of the form a(n) = m^b * (m+1)^d.
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..1000
John Derbyshire, Solutions to puzzles in my National Review Online Diary: June 2011
John Derbyshire, Solutions to puzzles in my National Review Online Diary: June 2011 [Cached copy, pdf version only, with permission]
Jonathan T. Rowell, Solution Sequences for the Keyboard Problem and its Generalizations, Journal of Integer Sequences, Vol. 18 (2015), Article 15.10.7.
FORMULA
a(n) = 4*a(n-6) for n >= 34. [corrected by Georg Fischer, Jun 09 2022]
a(n) = a(8;9;15;21;27) = 9; 12; 48; 192; 768 - corresponding to [C=2;2;3;4;5 below].
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.
a(n>=28) = 4^(C-R) * 5^R, where C = floor(n+2/6), R = (n+2) mod 6.
EXAMPLE
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.
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.
MATHEMATICA
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 *)
PROG
(Haskell)
-- See Theorem 5 in John Derbyshire link.
a193286 n = p n [] where
p 0 ks = product ks
p n [] = p (n-1) [1]
p n (k:ks)
| n < 0 = 0
| otherwise = max (p (n-1) ((k+1):ks)) (p (n-3) (1:k:ks))
-- Reinhard Zumkeller, Jul 22 2011, Jul 21 2011
(Python)
def a(n):
if n<8: return n
elif n==8: return 9
elif n>8 and n<=27:
c=max(1, ((n + 3)//6))
r=(n + 2)%c
q=((n + 2)//c) - 2
return q**(c - r)*(q + 1)**r
else:
q=((n + 2)//6)
r=(n + 2)%6
return 4**(q - r)*5**r
print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 27 2017, after Mathematica code
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
N. J. A. Sloane, Jul 20 2011
EXTENSIONS
Additional comment and formula from David Applegate, Jul 21 2011
More terms from Reinhard Zumkeller, Jul 22 2011, Jul 21 2011
Additional comments, formulas, examples and CrossRefs from Jonathan T. Rowell, Jul 30 2011
STATUS
approved