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.

A239942 a(n) = prime(n)! - prime(n - 1)!.

Original entry on oeis.org

4, 114, 4920, 39911760, 6187104000, 355681201075200, 121289412980736000, 25851895093784567808000, 8841761967887685215658639360000, 8213996892184183115771019264000000, 13763753083003506392138056763855339520000000
Offset: 2

Views

Author

Norman Koch, Mar 29 2014

Keywords

Examples

			a(3) = Prime(3)! - Prime(2)! = 5! - 3! = 120 - 6 = 114.
		

Crossrefs

Programs

  • 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 *)
  • PARI
    a(n)=prime(n)! - prime(n-1)!;
    vector(22,n,a(n+1)) \\ Joerg Arndt, Mar 31 2014
    
  • 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;
    }
    
  • 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

Formula

a(n) = A039716(n) - A039716(n-1).