login
Smallest image size for which the number of endofunctions (functions f:{1,2,...,n}->{1,2,...,n}) is a maximum.
1

%I #23 Nov 14 2014 10:27:32

%S 0,1,1,2,3,3,4,5,5,6,7,7,8,8,9,10,10,11,12,12,13,13,14,15,15,16,17,17,

%T 18,19,19,20,20,21,22,22,23,24,24,25,25,26,27,27,28,29,29,30,31,31,32,

%U 32,33,34,34,35,36,36,37,38,38,39,39,40,41,41,42,43,43

%N Smallest image size for which the number of endofunctions (functions f:{1,2,...,n}->{1,2,...,n}) is a maximum.

%C a(n) is the smallest number of elements in the image for which the number of functions f:{1,2,...,n}->{1,2,...,n} is a maximum.

%H Alois P. Heinz, <a href="/A194640/b194640.txt">Table of n, a(n) for n = 0..1000</a>

%F a(n) = arg max_{k=0..n} Stirling2(n,k) * k! * C(n,k) for n!=2, a(2) = 1.

%F a(n) = arg max_{k=0..n} A090657(n,k) for n!=2, a(2) = 1.

%e a(3) = 2 because there are 18 functions from {1,2,3} into {1,2,3} that have two elements in their image, 3 functions have one and 6 functions that have three elements in their image.

%p T:= proc(n, k) option remember;

%p if k=n then n!

%p elif k=0 or k>n then 0

%p else n * (T(n-1, k-1) + k/(n-k) * T(n-1, k))

%p fi

%p end:

%p a:= proc(n) local i, k, m, t;

%p m, i:= 0, 0;

%p for k to n do

%p t:= T(n, k);

%p if t>m then m, i:= t, k fi

%p od; i

%p end:

%p seq(a(n), n=0..50); # _Alois P. Heinz_, Sep 08 2011

%t Prepend[Flatten[Table[Flatten[First[Position[Table[StirlingS2[n, k] Binomial[n, k] k!, {k, 1, n}],Max[Table[StirlingS2[n, k] Binomial[n, k] k!, {k, 1, n}]]]]], {n, 1,50}]], 0]

%Y Cf. A000312 (number of endofunctions), A090657.

%K nonn

%O 0,4

%A _Geoffrey Critzer_, Aug 31 2011