OFFSET
2,1
LINKS
Michael De Vlieger, Table of n, a(n) for n = 2..87
EXAMPLE
a(3) = Prime(3)! - Prime(2)! = 5! - 3! = 120 - 6 = 114.
MAPLE
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
KEYWORD
nonn
AUTHOR
Norman Koch, Mar 29 2014
STATUS
approved