OFFSET
2,1
COMMENTS
All terms are positive integers, no zero term.
The Mathematica program generates first 99 items and the function AllSplits[n_] can be used to generate a(n) for any n > 1.
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 2..1000
EXAMPLE
n=2: prime(2)=3 = 2 + 1 = 2^2 - 1, so a(2)=2;
n=3: prime(3)=5 = 2^2 + 1, so a(3)=1;
...
n=10: prime(10)=29, int(sqrt(29))=5, 29 = 2+3^3 = 2^2+5^2 = 2^2*5+3^2 = 2^3*3+5 = 2*3*5-1, so a(10)=5.
MATHEMATICA
AllPrimes[k_] :=
Module[{p, maxfactor, pset}, p = Prime[k];
maxfactor = NextPrime[IntegerPart[Sqrt[p]] + 1, -1];
If[maxfactor == -2, pset = {2}, p0 = 2; pset = {2};
While[p0 = NextPrime[p0]; p0 <= maxfactor,
pset = Union[pset, {p0}]]]; pset];
NextIntegerWithFactor[seed_, fset_] :=
Module[{m, a, l, i, fset1}, m = seed - 1;
While[m++; If[Mod[m, 2] == 1, m++]; a = FactorInteger[m];
l = Length[a]; fset1 = {};
Do[fset1 = Union[fset1, {a[[i]][[1]]}], {i, 1, l}];
Intersection[fset1, fset] != fset1]; m];
FactorSet[seed_] :=
Module[{fset2, a, l, i}, a = FactorInteger[seed]; l = Length[a];
fset2 = {}; Do[fset2 = Union[fset2, {a[[i]][[1]]}], {i, 1, l}];
fset2]; SplitPrime[n_, q0_] :=
Module[{p, pset, q, r, rp, fs, rs, qs}, p = Prime[n];
pset = AllPrimes[n]; q = q0;
While[q++; q = NextIntegerWithFactor[q, pset]; r = p - q;
rp = Abs[r]; fs = FactorSet[rp];
rs = Complement[pset, FactorSet[q]];
qs = Intersection[fs,
rs]; (fs != {1}) && (fs != qs) && (q <= (p + 1))]; {p, q, r} ];
AllSplits[n_] :=
Module[{q, ss, spls}, q = 0; spls = {};
While[ss = SplitPrime[n, q]; q = ss[[2]];
If[q <= (Prime[n] + 1), spls = Union[spls, {ss}]];
q < (Prime[n] + 1)]; spls]; Table[
Length[AllSplits[i]], {i, 2, 100}] (* Lei Zhou *)
zhouAbleCount[n_] := Length[Select[Range[-1, Prime[n], 2], GCD[#, Prime[n] - #] == 1 && FactorInteger[#][[-1, 1]] <= Sqrt[Prime[n]] && (IntegerQ[Log[2, Prime[n] - #]] || FactorInteger[Prime[n] - #][[-1, 1]] <= Sqrt[Prime[n]]) &]]; Table[zhouAbleCount[n], {n, 2, 100}] (* Alonso del Arte, Oct 03 2011 *)
PROG
(Haskell)
a196526 n = length [c | let p = a000040 n,
c <- [-1, 1..p-1], let b = p - c,
gcd b c == 1,
a006530 b ^ 2 < p || p == 3, a006530 c ^ 2 < p]
-- Reinhard Zumkeller, Oct 04 2001
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Lei Zhou, Oct 03 2011
STATUS
approved