%I N0107 #93 Aug 30 2024 10:51:11
%S 2,2,3,7,25,121,721,5041,40321,362881,3628801,39916801,479001601,
%T 6227020801,87178291201,1307674368001,20922789888001,355687428096001,
%U 6402373705728001,121645100408832001
%N a(n) = n! + 1.
%C "For n = 4, 5 and 7, n!+1 is a square. Sierpiński asked if there are any other values of n with this property." p. 82 of Ogilvy and Anderson (see A146968).
%C Number of {12,12*,1*2,21*,2*1}-avoiding signed permutations in the hyperoctahedral group.
%C After Wilson's Theorem: if (n+1) is prime then (n+1) is the smallest prime factor of a(n). - _Karl-Heinz Hofmann_, Aug 21 2024
%D C. Stanley Ogilvy and John T. Anderson, Excursions in Number Theory, Oxford University Press, 1966, p. 82.
%D Wacław Sierpiński, On some unsolved problems of arithmetics, Scripta Mathematica, vol. 25 (1960), p. 125.
%D N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
%H Vincenzo Librandi, <a href="/A038507/b038507.txt">Table of n, a(n) for n = 0..300</a>
%H INRIA Algorithms Project, <a href="http://ecs.inria.fr/services/structure?nbr=763">Encyclopedia of Combinatorial Structures 763</a> and <a href="http://ecs.inria.fr/services/structure?nbr=834">Encyclopedia of Combinatorial Structures 834</a>
%H T. Mansour and J. West, <a href="https://arxiv.org/abs/math/0207204">Avoiding 2-letter signed patterns</a>, arXiv:math/0207204 [math.CO], 2002.
%H R. Mestrovic, <a href="http://arxiv.org/abs/1202.3670">Euclid's theorem on the infinitude of primes: a historical survey of its proofs (300 BC--2012) and another new proof</a>, arXiv preprint arXiv:1202.3670 [math.HO], 2012-2023. - From N. J. A. Sloane, Jun 13 2012
%H Gerard P. Michon, <a href="http://www.numericana.com/wilson.htm">Wilson's Theorem</a>
%H Hisanori Mishima, <a href="http://www.asahi-net.or.jp/~KC2H-MSM/mathland/matha1/matha102.htm">Factorizations of many number sequences</a>
%H Hisanori Mishima, <a href="http://www.asahi-net.or.jp/~KC2H-MSM/mathland/matha1/matha104.htm">Factorizations of many number sequences</a>
%H Andrew Walker, <a href="http://www.uow.edu.au/~ajw01/ecm/curves.html">Factors of n! +- 1</a>
%H Arthur T. White, <a href="http://dx.doi.org/10.1017/S0305004100061053">Ringing the changes</a>, Math. Proc. Cambridge Philos. Soc. 94 (1983), no. 2, 203-215.
%H Robert G. Wilson v, <a href="/A038507/a038507.txt">Explicit factorizations</a>
%H Jun Yan, <a href="https://arxiv.org/abs/2404.07958">Results on pattern avoidance in parking functions</a>, arXiv:2404.07958 [math.CO], 2024. See p. 4.
%H <a href="/index/Fa#factorial">Index entries for sequences related to factorial numbers</a>
%F a(n) = n * (a(n-1) - 1) + 1. - _Reinhard Zumkeller_, Mar 20 2013
%F 0 = a(n)*(a(n+1) - 5*a(n+2) + 5*a(n+3) - a(n+4)) + a(n+1)*(a(n+1) + a(n+2) - 6*a(n+3) + 2*a(n+4)) + a(n+2)*(3*a(n+2) - a(n+3) - a(n+4)) + a(n+3)*(a(n+3)) if n>=0. - _Michael Somos_, Apr 23 2014
%F From _Ilya Gutkovskiy_, Jan 20 2017: (Start)
%F E.g.f: exp(x) + 1/(1 - x).
%F Sum_{n>=0} 1/a(n) = A217702. (End)
%e G.f. = 2 + 2*x + 3*x^2 + 7*x^3 + 25*x^4 + 121*x^5 + 721*x^6 + 5041*x^7 + ...
%t Range[0,20]!+1 (* _Harvey P. Dale_, May 06 2012 *)
%o (Magma) [Factorial(n) +1: n in [0..25]]; // _Vincenzo Librandi_, Jul 20 2011
%o (Maxima) A038507(n):= n!+1$
%o makelist(A038507(n),n,0,30); /* _Martin Ettl_, Nov 03 2012 */
%o (PARI) a(n)=n!+1 \\ _Charles R Greathouse IV_, Nov 20 2012
%o (Haskell)
%o a038507 = (+ 1) . a000142
%o a038507_list = 2 : f 1 2 where
%o f x y = z : f (x + 1) z where z = x * (y - 1) + 1
%o -- _Reinhard Zumkeller_, Mar 20 2013
%o (Python)
%o from math import factorial
%o def A038507(n): return factorial(n) + 1 # _Karl-Heinz Hofmann_, Aug 21 2024
%Y Cf. A000142, A002583, A002981, A033312, A051301, A056111, A217702
%K nonn,easy,nice
%O 0,1
%A _N. J. A. Sloane_
%E Additional comments from _Jason Earls_, Apr 01 2001
%E Numericana.com URL fixed by _Gerard P. Michon_, Mar 30 2010
%E Entry revised by _N. J. A. Sloane_, Jun 10 2012