A193286 a(n) is the maximal number of a's that can be produced in a blank document with n "keystrokes".
1, 2, 3, 4, 5, 6, 7, 9, 12, 16, 20, 25, 30, 36, 48, 64, 80, 100, 125, 150, 192, 256, 320, 400, 500, 625, 768, 1024, 1280, 1600, 2000, 2500, 3125, 4096, 5120, 6400, 8000, 10000, 12500, 16384, 20480, 25600, 32000, 40000, 50000, 65536, 81920, 102400, 128000, 160000, 200000, 262144, 327680
Offset: 1
Examples
For n=25, C = floor(28/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.
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.
Crossrefs
Programs
-
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
-
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 *)
-
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
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=9..27) = Q^(C-R) * (Q+1)^R where C = floor((n+3)/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.
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
Comments