login
a(n) = (n+1)^n mod n^n.
6

%I #34 May 23 2023 14:57:50

%S 0,1,10,113,1526,24337,450066,9492289,225159022,5937424601,

%T 172385029466,5465884225969,187964560069638,6968912374274593,

%U 277133723845128226,11767703728247765249,531431035966023003614,25434534147318166381993,1286040688679372821752042

%N a(n) = (n+1)^n mod n^n.

%H G. C. Greubel, <a href="/A176824/b176824.txt">Table of n, a(n) for n = 1..380</a>

%F From _Peter Bala_, Sep 12 2012: (Start)

%F a(n) = (n+1)^n - 2*n^n (since 2*n^n <= (n+1)^n < 3*n^n for n >= 1).

%F In terms of the tree function T(x) = Sum_{n >= 1} n^(n-1)*x^n/n! of A000169 the e.g.f. is T(x)*(2*x + T(x)*(T(x)-2))/(x^2*(T(x)-1)^3) = x + 10*x^2/2! + 113*x^3/3! + ... . (End)

%F a(n) = Sum_{i=1..n-1} C(n,i-1)*i^(i-1)*(n-i)^(n-i). - _Vladimir Kruchinin_, Sep 07 2015

%F a(n) = A000169(n+1) - 2*A000312(n). - _Michel Marcus_, Sep 07 2015, after _Peter Bala_

%p A176824:=n->(n+1)^n mod n^n: seq(A176824(n), n=1..25); # _Wesley Ivan Hurt_, Sep 10 2015

%t Table[Mod[(n+1)^n, n^n], {n,30}]

%o (Magma) [(n+1)^n mod n^n: n in [1..20]]; // _Vincenzo Librandi_, Sep 07 2015

%o (PARI) first(m)=vector(m,i,((i+1)^i) % (i^i)) \\ _Anders Hellström_, Sep 07 2015

%o (SageMath) [(n+1)^n%n^n for n in range(1,31)] # _G. C. Greubel_, May 23 2023

%Y Cf. A000169, A000312, A048160.

%K nonn,easy

%O 1,3

%A _Vladimir Joseph Stephan Orlovsky_, Apr 26 2010

%E a(19) from _Vincenzo Librandi_, Sep 07 2015