login
a(n) is the number of divisors of n that are 1 above or 1 below a divisor of either n+1 or n-1.
2

%I #36 Jan 12 2022 10:59:58

%S 1,2,2,2,2,2,3,3,2,2,2,2,2,4,3,2,2,2,3,3,2,2,4,3,2,3,3,2,2,2,3,3,2,4,

%T 4,2,2,3,3,2,2,2,3,4,2,2,4,3,2,3,3,2,3,3,3,3,2,2,2,2,2,5,4,3,3,2,3,3,

%U 2,2,2,2,2,4,3,3,3,2,5,4,2,2,4,3,2,3,3

%N a(n) is the number of divisors of n that are 1 above or 1 below a divisor of either n+1 or n-1.

%H Antti Karttunen, <a href="/A349949/b349949.txt">Table of n, a(n) for n = 2..20000</a>

%F a(p) = 2 for odd prime p. - _Chai Wah Wu_, Dec 30 2021

%e a(2) = 1 because 2 and 0 are not divisors of either 1 or 3, but 3 = 2+1 is a divisor of 3.

%e 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).

%t 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 *)

%o (Python)

%o from sympy import divisors

%o def aupton(nn):

%o alst, prevdivs, divs, nextdivs = [], set(), {1}, {1, 2}

%o for n in range(2, nn+1):

%o prevdivs, divs, nextdivs = divs, nextdivs, set(divisors(n+1))

%o neighdivs = prevdivs | nextdivs

%o an = sum(1 for d in divs if {d-1, d+1} & neighdivs != set())

%o alst.append(an)

%o return alst

%o print(aupton(88)) # _Michael S. Branicky_, Dec 06 2021

%o (Python)

%o 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

%o (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

%Y Cf. A000005.

%K nonn

%O 2,2

%A _Tejo Vrush_, Dec 06 2021

%E a(6), a(12), a(14), a(18) corrected and a(31) and beyond from _Michael S. Branicky_, Dec 06 2021