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.

A241425 Largest number k > 0 such that n + k! and n - k! are both prime, or 0 if no such k exists.

This page as a plain text file.
%I A241425 #24 Jul 27 2020 04:45:11
%S A241425 0,0,0,1,2,1,0,0,2,0,3,1,3,0,2,0,3,1,0,0,2,0,3,0,3,0,0,0,4,1,0,0,0,0,
%T A241425 4,0,4,0,2,0,0,1,4,0,2,0,4,0,0,0,0,0,3,0,4,0,0,0,0,1,0,0,0,0,4,0,3,0,
%U A241425 2,0,0,1,3,0,0,0,4,0,0,0,2,0,4,0,4,0,0,0,0,0,0,0,0,0,3
%N A241425 Largest number k > 0 such that n + k! and n - k! are both prime, or 0 if no such k exists.
%C A241425 If k > n, n - k! is surely negative and, therefore, not prime.
%C A241425 a(n) < A020639(n). - _Robert Israel_, Aug 10 2014
%H A241425 Robert Israel, <a href="/A241425/b241425.txt">Table of n, a(n) for n = 1..10000</a>
%p A241425 a:= proc(n)
%p A241425 local k;
%p A241425 for k from min(numtheory:-factorset(n))-1 to 1 by -1 do
%p A241425   if n > k! and isprime(n+k!) and isprime(n-k!) then return(k) fi
%p A241425 od:
%p A241425 0
%p A241425 end proc:
%p A241425 a(1):= 0:
%p A241425 seq(a(n),n=1..100); # _Robert Israel_, Aug 10 2014
%t A241425 a[n_] := Module[{k}, For[k = FactorInteger[n][[1, 1]], k >= 1, k--, If[n > k! && PrimeQ[n + k!] && PrimeQ[n - k!], Return[k]]]; 0];
%t A241425 a[1] = 0;
%t A241425 Array[a, 100] (* _Jean-François Alcover_, Jul 27 2020, after Maple *)
%o A241425 (PARI)
%o A241425 a(n)=forstep(k=n,1,-1,if(ispseudoprime(n+k!)&&ispseudoprime(n-k!),return(k)))
%o A241425 n=1;while(n<150,print1(a(n),", ");n++)
%Y A241425 Cf. A020639, A245716, A241423, A241424.
%K A241425 nonn
%O A241425 1,5
%A A241425 _Derek Orr_, Aug 08 2014