cp's OEIS Frontend

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.

A002021 Pile of coconuts problem: (n-1)*(n^n - 1), n even; n^n - n + 1, n odd.

This page as a plain text file.
%I A002021 M3114 N1262 #58 Apr 16 2025 08:43:56
%S A002021 1,3,25,765,3121,233275,823537,117440505,387420481,89999999991,
%T A002021 285311670601,98077104930805,302875106592241,144456088732254195,
%U A002021 437893890380859361,276701161105643274225,827240261886336764161,668888937280041138782191,1978419655660313589123961
%N A002021 Pile of coconuts problem: (n-1)*(n^n - 1), n even; n^n - n + 1, n odd.
%C A002021 This is a generalization (from n = 5) of Ben Ames Williams's published problem. For a given n, the problem is effectively as follows. A successful monkey-share process removes 1 coconut for a monkey followed by an exact share of 1/n from the coconut pile. Determine the least initial number of coconuts for a monkey-share to succeed n times, leaving a multiple of n to be shared equally at the end. The problem in the D'Agostino link is slightly different, requiring a coconut for the monkey in the final division. - _Peter Munn_, Jun 14 2023
%D A002021 N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
%D A002021 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H A002021 T. D. Noe, <a href="/A002021/b002021.txt">Table of n, a(n) for n = 1..100</a>
%H A002021 Anonymous, <a href="http://www.f1compiler.com/samples/Sailors%20Monkey%20Coconuts.f1.html">The Monkey and the Coconuts</a> (with FormulaOne program)
%H A002021 Santo D'Agostino, <a href="https://fomap.org/2011/05/13/the-coconut-problem/">"The Coconut Problem"; Updated With Solution</a>, May 2011.
%H A002021 Mark Richardson, <a href="https://doi.org/10.15200/winn.147175.52128">A Needlessly Complicated and Unhelpful Solution to Ben Ames Williams' Famous Coconuts Problem</a>, The Winnower, Authorea (2016) Vol. 3.
%H A002021 R. S. Underwood and Robert E. Moritz, <a href="http://www.jstor.org/stable/2298601">Problem 3242</a>, Amer. Math. Monthly, 35 (1928), 47-48.
%H A002021 Robert G. Wilson v, <a href="/A007376/a007376.pdf">Letter to N. J. A. Sloane, Oct. 1993</a>
%F A002021 E.g.f.: (1-x)*exp(x)-(W(x)+2)*(2*W(x)+1)/(2*(1+W(x))^3)-W(-x)/(2*(1+W(-x))^3) where W is the Lambert W function. - _Robert Israel_, Aug 26 2016
%F A002021 a(n) = 1-n-(-n)^n+(1+(-1)^n)*n^(n+1)/2. - _Wesley Ivan Hurt_, Nov 09 2023
%p A002021 seq(`if`(n::even, (n-1)*(n^n - 1),n^n-n+1),n=1..30); # _Robert Israel_, Aug 26 2016
%t A002021 Table[If[EvenQ[n],(n-1)(n^n-1),n^n-n+1],{n,30}] (* _Harvey P. Dale_, Apr 21 2012 *)
%o A002021 (Python)
%o A002021 def a(n): return (n-1)*(n**n - 1) if n%2 == 0 else n**n - n + 1
%o A002021 print([a(n) for n in range(1, 20)]) # _Michael S. Branicky_, Feb 07 2022
%Y A002021 Cf. A002022, A006091.
%K A002021 easy,nonn,nice
%O A002021 1,2
%A A002021 _N. J. A. Sloane_
%E A002021 More terms from _Harvey P. Dale_, Apr 21 2012