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.

Showing 1-8 of 8 results.

A005165 Alternating factorials: n! - (n-1)! + (n-2)! - ... 1!.

Original entry on oeis.org

0, 1, 1, 5, 19, 101, 619, 4421, 35899, 326981, 3301819, 36614981, 442386619, 5784634181, 81393657019, 1226280710981, 19696509177019, 335990918918981, 6066382786809019, 115578717622022981, 2317323290554617019, 48773618881154822981
Offset: 0

Views

Author

Keywords

Comments

Conjecture: for n > 2, smallest prime divisor of a(n) > n. - Gerald McGarvey, Jun 19 2004
Rebuttal: This is not true; see Zivkovic link (Math. Comp. 68 (1999), pp. 403-409) has demonstrated that 3612703 divides a(n) for all n >= 3612702. - Paul Jobling, Oct 18 2004
Conjecture: For n>1, a(n) is the number of lattice paths from (0,0) to (n+1,0) that do not cross above y=x or below the x-axis using up-steps +(1,a) and down-steps +(1,-b) where a and b are positive integers. For example, a(3) = 5: [(1,1)(1,1)(1,1)(1,-3)], [(1,1)(1,-1)(1,3)(1,-3)], [(1,1)(1,-1)(1,2)(1,-2)], [(1,1)(1,-1)(1,1)(1,-1)] and [(1,1)(1,1)(1,-1)(1,-1)]. - Nicholas Ham, Aug 23 2015
Ham's claim is true for n=2. We proceed with a proof for n>2 by induction. On the j-th step, from (j-1,y) to (j,y'), there are j options for y': 0, 1, ..., y-1, y+1, ..., j. Thus there are n! possible paths from (0,0) to x=n that stay between y=0 and y=x. (Then the final step is determined.) However, because +(1,0) is not an allowable step, we cannot land on (n,0) on the n-th step. Therefore, the number of acceptable lattice paths is n! - a(n-1). - Danny Rorabaugh, Nov 30 2015

References

  • Richard K. Guy, Unsolved Problems in Number Theory, 3rd Edition, Springer, 2004, Section B10, pp. 152-153.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • GAP
    List([0..30],n->Sum([1..n],i->(-1)^(n-i)*Factorial(i))); # Muniru A Asiru, Jun 01 2018
  • Haskell
    a005165 n = a005165_list !! n
    a005165_list = 0 : zipWith (-) (tail a000142_list) a005165_list
    -- Reinhard Zumkeller, Jul 21 2013
    
  • Maple
    A005165 := proc(n) local i; add((-1)^(n-i)*i!,i=1..n); end;
  • Mathematica
    nn=25;With[{fctrls=Range[nn]!},Table[Abs[Total[Times@@@Partition[ Riffle[ Take[ fctrls,n],{1,-1}],2]]],{n,nn}]] (* Harvey P. Dale, Dec 10 2011 *)
    a[0] = 0; a[n_] := n! - a[n - 1]; Array[a, 26, 0] (* Robert G. Wilson v, Aug 06 2012 *)
    RecurrenceTable[{a[n] == n! - a[n - 1], a[0] == 0}, a, {n, 0, 20}] (* Eric W. Weisstein, Jul 27 2017 *)
    AlternatingFactorial[Range[0, 20]] (* Eric W. Weisstein, Jul 27 2017 *)
    a[n_] = (-1)^n (Exp[1]((-1)^n Gamma[-1-n,1] Gamma[2+n] - ExpIntegralEi[-1]) - 1)
    Table[a[n] // FullSimplify, {n, 0, 20}] (* Gerry Martens, May 22 2018 *)
  • PARI
    a(n)=if(n<0,0,sum(k=0,n-1,(-1)^k*(n-k)!))
    
  • PARI
    first(m)=vector(m,j,sum(i=0,j-1,((-1)^i)*(j-i)!)) \\ Anders Hellström, Aug 23 2015
    
  • PARI
    a(n)=round((-1)^n*(exp(1)*(gamma(n+2)*incgam(-1-n,1)*(-1)^n +eint1(1))-1)) \\ Gerry Martens, May 22 2018
    
  • Python
    a = 0
    f = 1
    for n in range(1, 33):
        print(a, end=",")
        f *= n
        a = f - a
    # Alex Ratushnyak, Aug 05 2012
    

Formula

a(0) = 0, a(n) = n! - a(n-1) for n > 0; also a(n) = n*a(n-2) + (n-1)*a(n-1) for n > 1. Sum_{n>=1} Pi^n/a(n) ~ 30.00005. - Gerald McGarvey, Jun 19 2004
E.g.f.: 1/(1-x) + exp(-x)*(e*(Ei(1,1)-Ei(1,1-x)) - 1). - Robert Israel, Dec 01 2015
a(n) = (-1)^n*(exp(1)*(gamma(n+2)*gamma(-1-n,1)*(-1)^n +Ei(1))-1). - Gerry Martens, May 22 2018
Sum_{n>=1} 1/a(n) = A343187. - Amiram Eldar, Jun 01 2023

A130308 Primes of the form [k!! - (k-1)!! + (k-2)!! - ... 1!!] - 1.

Original entry on oeis.org

5, 317, 1217216458429656137
Offset: 1

Views

Author

Keywords

Comments

The next term is too large to include.
The corresponding values of k are 4, 8, 32, 180, 264, 328, 1788, 2308, 5152, 7572, 13496, ... ; all these values are even since for k odd above 11 this form is divisible by 7. - Amiram Eldar, Jul 18 2019

Examples

			5 = 4!! - 3!! + 2!! - 1!! -1 = 8 - 3 + 2 - 1 - 1.
		

Crossrefs

Programs

  • Maple
    P:=proc(n) local a,i,j,k,w; for i from 1 by 1 to n do a:=0; for j from i by -1 to 0 do k:=j; w:=j-2; while w>0 do k:=k*w; w:=w-2; od; a:=a+k*(-1)^j od; if isprime(abs(a)-1) then print(abs(a)-1); fi; od; end: P(1000);
  • Mathematica
    f[n_] := Sum[(-1)^(n-k)*k!!, {k, 1, n}] - 1; Select[f/@Range[32], PrimeQ] (* Amiram Eldar, Jul 18 2019 *)

A130309 Primes of the form [k!! - (k-1)!! + (k-2)!! -....1!!] + 1.

Original entry on oeis.org

2, 3, 7, 67, 153979499670311863, 96139392052480758114443739387402080695373863
Offset: 1

Views

Author

Keywords

Comments

The next term is too large to include.
The corresponding values of k are 1, 2, 3, 4, 7, 31, 63, 263, 311, 371, 383, 10243, ... (1 and 2 give the same prime, 2). All these values except 2 and 4 are odd since for k even above 10 this form is divisible by 7. a(11) ~ 2.060 * 10^18317. - Amiram Eldar, Jul 18 2019

Examples

			2 = 1!! + 1 or 2!! - 1!! + 1.
7 = 4!! - 3!! + 2!! - 1!! +1 = 8 - 3 + 2 - 1 + 1.
		

Crossrefs

Programs

  • Maple
    P:=proc(n) local a,i,j,k,w; for i from 1 by 1 to n do a:=0; for j from i by -1 to 0 do k:=j; w:=j-2; while w>0 do k:=k*w; w:=w-2; od; a:=a+k*(-1)^j od; if isprime(abs(a)+1) then print(abs(a)+1); fi; od; end: P(1000);
  • Mathematica
    f[n_] := Sum[(-1)^(n-k)*k!!, {k, 1, n}] + 1; Select[f/@Range[2, 31], PrimeQ] (* Amiram Eldar, Jul 18 2019 *)

A361436 Primes of the form k! - Sum_{i=1..k-1} (-1)^(k-i)*i!.

Original entry on oeis.org

3, 7, 29, 139, 821, 5659, 44741, 515616581, 1389068025019, 2390389721955353653838200398484730341485707553165512827613149996957838364422981
Offset: 1

Views

Author

Jack Braxton, Mar 11 2023

Keywords

Comments

Primes of the form k! + A005165(k - 1).

Examples

			139 is in the sequence because it is 5! + (4! - 3! + 2! - 1!).
		

Crossrefs

Cf. A005165 (alternating factorials), A071828, A361437 (the k's).

Programs

  • PARI
    \\ here b(n) is n! + A005165(n-1).
    b(n) = {n! - sum(i=1, n-1, (-1)^(n-i)*i!)}
    { for(k=1, 150, if(ispseudoprime(b(k)), print1(b(k), ", "))) } \\ Andrew Howroyd, Mar 12 2023

A361437 Numbers k such that k! - Sum_{i=1..k-1} (-1)^(k-i)*i! is prime.

Original entry on oeis.org

2, 3, 4, 5, 6, 7, 8, 12, 15, 58, 59, 102, 111, 118, 164, 291, 589, 685, 1671, 1900, 1945, 4905, 9564
Offset: 1

Views

Author

Jack Braxton, Mar 11 2023

Keywords

Comments

Numbers k such that k! + A005165(k - 1) is prime.
a(23) > 7000. - Hugo Pfoertner, Mar 15 2023

Examples

			2 is in the sequence because 2! + 1! = 3.
3 is in the sequence because 3! + (2! - 1!) = 7.
4 is in the sequence because 4! + (3! - 2! + 1!) = 29.
5 is in the sequence because 5! + (4! - 3! + 2! - 1!) = 139.
		

Crossrefs

Cf. A361436 (the corresponding primes).
Cf. A001272, A005165 (alternating factorials), A071828.

Programs

  • PARI
    isok(k) = isprime(k! + sum(i=1, k-1, (-1)^(i+1)*(k-i)!)); \\ Michel Marcus, Mar 12 2023

Extensions

Missing a(10) inserted and a(12)-a(18) from Andrew Howroyd, Mar 12 2023
a(19)-a(22) from Hugo Pfoertner, Mar 13 2023
a(23) from Michael S. Branicky, Oct 02 2024

A119555 Primes in the sequence f(n) = f(n-1)+((-1)^n)*n!, with f(0)=0.

Original entry on oeis.org

19, 619, 35899, 3301819, 468544077492065936712052044718939948687543330546977719976017418129955876663406131164377030450551575840099843957105136480237871017419158043635450756712088769133544426722033165168878328322819566779381528981882285541609256481166622331374702000809600061055686236758821446539362161635577019
Offset: 1

Views

Author

Keywords

Comments

f(n) = (-1)^n*A005165(n). The primes are those terms in A071828 which correspond to even n values in A001272: n = 4, 6, 8, 10, 160, 4998, 9158, 11164 (the last three are only probable primes). 3612703 divides f(n) for n >= 3612702, so the sequence is finite. - Jens Kruse Andersen, Jul 04 2014

Examples

			f(0)=0, f(1) = 0+((-1)^1)*1! = -1, f(2) = -1+((-1)^2)*2! = 1, f(3) = 1+((-1)^3)*3! = -5, f(4) = -5+((-1)^4)*4! = 19, which is prime, so 19 is the first term of the sequence.
		

References

  • G. Balzarotti and P. P. Lava, Le sequenze di numeri interi, Hoepli, 2008, p. 160.

Crossrefs

Programs

  • Maple
    P:=proc(n) local i,j; j:=0; for i from 1 by 1 to n do j:=j+((-1)^i)*i!; if isprime(j) then print(j); fi; od; end: P(100);
  • Mathematica
    nxt[{n_,a_}]:={n+1,a+(-1)^(n+1) (n+1)!}; Select[NestList[nxt,{0,0},200][[All,2]],#>0&&PrimeQ[#]&] (* Harvey P. Dale, Jan 22 2017 *)

Extensions

Offset changed to 1 (this is a list) from Bruno Berselli, Feb 16 2012
Formula in name corrected by Jens Kruse Andersen, Jul 04 2014

A290045 Primes in A290044.

Original entry on oeis.org

7, 41, 176075177, 49127973630377
Offset: 1

Views

Author

XU Pingya, Jul 19 2017

Keywords

Comments

For n < 20, A290044(n) are prime when n = {2, 3, 9, 13}.
For n >= 20, 19|A290044(n). Therefore there are only 4 terms in this sequence.

Examples

			41 = |0!! - 2!! + 4!! - 6!!| is prime.
		

Crossrefs

Programs

  • Mathematica
    Select[Table[Abs@ Sum[(-1)^k*(2 k)!!, {k, 0, n}], {n, 0, 60}], PrimeQ] (* Michael De Vlieger, Jul 19 2017 *)

A290047 Primes in A290046.

Original entry on oeis.org

2, 45181, 6290021506693847759, 25266964023001914822246560759, 10384129888710330539039375199241
Offset: 1

Views

Author

XU Pingya, Jul 19 2017

Keywords

Comments

For n < 26, A290046(n) are primes when n = {1, 4, 11, 15, 16}.
For n >= 26, 41|A290046(n). Therefore there are only 5 terms in this sequence.

Examples

			45181 = |0!! - 3!! + 6!! - 9!! + 12!!| is prime.
		

Crossrefs

Programs

  • Mathematica
    Select[#, PrimeQ] &@ Table[Abs@ Sum[(-1)^k*(3 k)!!, {k, 0, n}], {n, 0, 30}] (* Michael De Vlieger, Jul 19 2017 *)
Showing 1-8 of 8 results.