OFFSET
2,1
LINKS
Robert Israel, Table of n, a(n) for n = 2..719
EXAMPLE
a(6) = 55 = 9*6 +1 = 11*5 and 6 = 2*3 are both of prime signature p*q, where p and q are primes.
MAPLE
f:= proc(n) local k, s, p, best, q, r, x;
s:= ps(n);
if nops(s) = 1 then
s:= s[1]; p:= 1; do p:= nextprime(p); if p^s mod n = 1 then return p^s fi od
elif nops(s) = 2 then
p:= 1; best:= infinity;
do
p:=nextprime(p);
if n mod p = 0 then next fi;
if 2^s[1]*p^s[2] > best then return best fi;
if [msolve(x^s[1]*p^s[2]=1, n)]=[] then next fi;
q:= 1;
do
q:= nextprime(q);
if q = p or n mod q = 0 then next fi;
r:= q^s[1]*p^s[2];
if r > best then break fi;
if r mod n = 1 then best:= r fi;
od
od
fi;
for k from 1 by n do if ps(k) = s then return k fi od
end proc:
map(f, [$1..100]); # Robert Israel, Mar 23 2021
PROG
(PARI) a(n) = my(ps = vecsort(factor(n)[, 2]), k = 1); while (vecsort(factor(k*n+1)[, 2]) != ps, k++); return (k*n+1); \\ Michel Marcus, Sep 15 2013; corrected Jun 14 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Jul 01 2003
EXTENSIONS
More terms from David Wasserman, Jan 12 2005
STATUS
approved