This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A054404 #34 Feb 16 2025 08:32:42 %S A054404 0,1,1,1,2,2,2,3,3,3,4,4,5,5,5,6,6,6,7,7,8,8,8,9,9,9,10,10,10,11,11, %T A054404 12,12,12,13,13,13,14,14,15,15,15,16,16,16,17,17,17,18,18,19,19,19,20, %U A054404 20,20,21,21,22,22,22,23,23,23,24,24,24,25,25,26,26,26,27,27,27 %N A054404 Number of daughters to wait before picking in sultan's dowry problem with n daughters. %C A054404 The correct rule can be found in the Gardner reference (p. 60) and in the Wikipedia article (see link): if the number of candidates is n, then the optimal r (the number of candidates to skip) is the r that maximizes (r/n)(1/r+1/(r+1)+...+1/(n-1)). - Zvi Mendlowitz (zvi113(AT)zahav.net.il), Jul 12 2007 %D A054404 M. Gardner, My Best Mathematical and Logic Puzzles, Dover, 1994 %H A054404 R. J. Mathar, <a href="/A054404/b054404.txt">Table of n, a(n) for n = 1..1000</a> %H A054404 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/SultansDowryProblem.html">Sultan's Dowry Problem.</a> %H A054404 Wikipedia, <a href="http://en.wikipedia.org/wiki/Secretary_problem">Secretary problem</a>. %F A054404 a(n) = the integer r that maximizes (r/n)(1/r+1/(r+1)+...+1/(n-1)). - Zvi Mendlowitz (zvi113(AT)zahav.net.il), Jul 12 2007 %p A054404 A054404 := proc(n) %p A054404 local r ; %p A054404 r := 0 ; %p A054404 sr := 0 ; %p A054404 for s from 1 to n do %p A054404 p := s/n*add(1/i,i=s..n-1) ; %p A054404 if p > sr then %p A054404 r := s ; %p A054404 sr := p ; %p A054404 end if; %p A054404 end do; %p A054404 return r; %p A054404 end proc: # _R. J. Mathar_, Jun 09 2013 %t A054404 a[n_] := r /. Last[ Maximize[ {(r/n)*Sum[1/k, {k, r, n - 1}], 0 <= r < n/2}, r, Integers]]; a[1] = 0; a[2] = 1; Table[a[n], {n, 1, 75}] (* _Jean-François Alcover_, Dec 13 2011, after Zvi Mendlowitz *) %t A054404 (* The code above may not work in Mma 8 *) %t A054404 PR[n_, r_] := (r/n)*Sum[1/k, {k, r, n - 1}]; %t A054404 maxi[li_] := {Do[If[li[[n + 1]] < %t A054404 li[[n]], aux = n; Break[]], {n, 1, Length[li] - 1}], aux}[[2]]; %t A054404 SEQ[1] = 0; SEQ[2] = 1; SEQ[n_] := maxi[Table[PR[n, i], {i, 1, n - 1}]]; %t A054404 Table[SEQ[n], {n, 1, 133}] (* _José María Grau Ribas_, May 11 2013 *) %t A054404 a[1]=0; a[2]=1; a[n_] := Block[{r}, r /. Last@ Maximize[{(r/n) * (PolyGamma[0, n] - PolyGamma[0, r]), 1 <= r < n/2}, r, Integers]]; Array[a, 75] (* _Giovanni Resta_, May 11 2013 *) %K A054404 nonn %O A054404 1,5 %A A054404 _Eric W. Weisstein_ %E A054404 Corrected by Zvi Mendlowitz (zvi113(AT)zahav.net.il), Jul 12 2007