OFFSET
2,2
LINKS
Antti Karttunen, Table of n, a(n) for n = 2..20000
FORMULA
a(p) = 2 for odd prime p. - Chai Wah Wu, Dec 30 2021
EXAMPLE
a(2) = 1 because 2 and 0 are not divisors of either 1 or 3, but 3 = 2+1 is a divisor of 3.
a(6) = 2 since the divisors of 6 are 1, 2, 3, and 6; those of 5 are 1 and 5; those of 7 are 1 and 7; and, regarding {1, 5, 7}, neither 1-1 = 0 nor 1+1 = 2 are in the set, neither 3-1 = 2 nor 3+1 = 4 is, but 2-1 = 1 is, and 6-1 = 5 is (as is 6+1 = 7).
MATHEMATICA
Table[DivisorSum[n, 1 &, If[# == 1, Or[Mod[n - 1, # + 1] == 0, Mod[n + 1, # + 1] == 0], AnyTrue[# + {-1, 1}, Or[Mod[n - 1, #] == 0, Mod[n + 1, #] == 0] &]] &], {n, 2, 88}] (* Michael De Vlieger, Dec 06 2021 *)
PROG
(Python)
from sympy import divisors
def aupton(nn):
alst, prevdivs, divs, nextdivs = [], set(), {1}, {1, 2}
for n in range(2, nn+1):
prevdivs, divs, nextdivs = divs, nextdivs, set(divisors(n+1))
neighdivs = prevdivs | nextdivs
an = sum(1 for d in divs if {d-1, d+1} & neighdivs != set())
alst.append(an)
return alst
print(aupton(88)) # Michael S. Branicky, Dec 06 2021
(Python)
def A349949(n): return sum(1 for m in filter(lambda d:not (((n-1) % (d-1) if d > 1 else True) and (n-1) % (d+1) and ((n+1) % (d-1) if d > 1 else True) and (n+1) % (d+1)), divisors(n, generator=True))) # Chai Wah Wu, Dec 30 2021
(PARI) a(n) = my(sd=setunion(divisors(n-1), divisors(n+1))); sumdiv(n, d, (vecsearch(sd, d-1)>0) || (vecsearch(sd, d+1)>0)); \\ Michel Marcus, Dec 07 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Tejo Vrush, Dec 06 2021
EXTENSIONS
a(6), a(12), a(14), a(18) corrected and a(31) and beyond from Michael S. Branicky, Dec 06 2021
STATUS
approved