%I #17 Dec 07 2018 12:25:06
%S 1,2,-1,3,-1,5,-1,-1,-1,7,-1,13,-1,-1,-1,23,-1,-1,-1,43,-1,-1,-1,83,
%T -1,-1,-1,163,-1,-1,-1,-1,-1,-1,-1,-1,-1,317,-1,-1,-1,631,-1,-1,-1,
%U 1259,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2503,-1,-1,-1,5003,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
%N First differences of A116533.
%C Ignoring the +-1 terms, we obtain the sequence of Bertrand's primes A006992. If we consider sequences A_i={a_i(n)}, i=1,2,... with the same constructions as A116533, but with initials a_1(1)=2, a_2(1)=11, a_3(1)=17,..., a_m(1)=A164368(m),..., then the union of A_1,A_2,... contains all primes.
%p A116533 := proc(n) option remember; if n <=2 then n; else if isprime(procname(n-1)) then 2*procname(n-1) ; else procname(n-1)-1 ; end if; end if; end proc:
%p A163961 := proc(n) A116533(n+1)-A116533(n) ; end proc: # _R. J. Mathar_, Sep 03 2011
%t Differences@ Prepend[NestList[If[PrimeQ@ #, 2 #, # - 1] &, 2, 90], 1] (* _Michael De Vlieger_, Dec 06 2018 *)
%o (PARI) a116533(n) = if(n==1, 1, if(n==2, 2, if(ispseudoprime(a116533(n-1)), 2*a116533(n-1), a116533(n-1)-1)))
%o a(n) = a116533(n+1)-a116533(n) \\ _Felix Fröhlich_, Dec 06 2018
%o (PARI) lista(nn) = {va = vector(nn); va[1] = 1; va[2] = 2; for (n=3, nn, va[n] = if (isprime(va[n-1]), 2*va[n-1], va[n-1]-1);); vector(nn-1, n, va[n+1] - va[n]);} \\ _Michel Marcus_, Dec 07 2018
%Y Cf. A116533, A006992, A055496, A080359, A104272, A106108, A132199, A164368
%K sign
%O 1,2
%A _Vladimir Shevelev_, Aug 07 2009, Aug 14 2009