login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A239942
a(n) = prime(n)! - prime(n - 1)!.
1
4, 114, 4920, 39911760, 6187104000, 355681201075200, 121289412980736000, 25851895093784567808000, 8841761967887685215658639360000, 8213996892184183115771019264000000, 13763753083003506392138056763855339520000000
OFFSET
2,1
LINKS
Michael De Vlieger, Table of n, a(n) for n = 2..87
FORMULA
a(n) = A039716(n) - A039716(n-1).
EXAMPLE
a(3) = Prime(3)! - Prime(2)! = 5! - 3! = 120 - 6 = 114.
MAPLE
A239942:=n->ithprime(n)!-ithprime(n-1)!: seq(A239942(n), n=2..15); # Wesley Ivan Hurt, Aug 03 2014
MATHEMATICA
a239942[n_Integer] := Prime[n]! - Prime[n - 1]!; Table[a239942[n], {n, 2, 87}] (* Michael De Vlieger, Aug 03 2014 *)
PROG
(Perl)
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use Math::Prime::XS qw(is_prime);
use Memoize;
use Math::BigInt;
memoize('factorial');
use Data::Dumper;
my @primes = ();
for (2 .. 200) {
if(is_prime($_)) {
push @primes, $_;
}
}
for (1 .. $#primes) {
say factorial($primes[$_]) - factorial($primes[$_ - 1]);
}
sub factorial {
my $x = Math::BigInt->new(shift);
return $x if $x == 1;
return factorial($x - 1) * $x;
}
(PARI) a(n)=prime(n)! - prime(n-1)!;
vector(22, n, a(n+1)) \\ Joerg Arndt, Mar 31 2014
(Python)
from gmpy2 import mpz, fac
from sympy import prime
def A239942(n):
....return fac(mpz(prime(n))) - fac(mpz(prime(n-1))) # Chai Wah Wu, Aug 06 2014
CROSSREFS
Sequence in context: A194495 A260575 A275747 * A261457 A080482 A340277
KEYWORD
nonn
AUTHOR
Norman Koch, Mar 29 2014
STATUS
approved