cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A349949 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.

This page as a plain text file.
%I A349949 #36 Jan 12 2022 10:59:58
%S A349949 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 A349949 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 A349949 2,2,2,2,2,4,3,3,3,2,5,4,2,2,4,3,2,3,3
%N A349949 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 A349949 Antti Karttunen, <a href="/A349949/b349949.txt">Table of n, a(n) for n = 2..20000</a>
%F A349949 a(p) = 2 for odd prime p. - _Chai Wah Wu_, Dec 30 2021
%e A349949 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 A349949 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 A349949 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 A349949 (Python)
%o A349949 from sympy import divisors
%o A349949 def aupton(nn):
%o A349949     alst, prevdivs, divs, nextdivs = [], set(), {1}, {1, 2}
%o A349949     for n in range(2, nn+1):
%o A349949         prevdivs, divs, nextdivs = divs, nextdivs, set(divisors(n+1))
%o A349949         neighdivs = prevdivs | nextdivs
%o A349949         an = sum(1 for d in divs if {d-1, d+1} & neighdivs != set())
%o A349949         alst.append(an)
%o A349949     return alst
%o A349949 print(aupton(88)) # _Michael S. Branicky_, Dec 06 2021
%o A349949 (Python)
%o A349949 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 A349949 (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 A349949 Cf. A000005.
%K A349949 nonn
%O A349949 2,2
%A A349949 _Tejo Vrush_, Dec 06 2021
%E A349949 a(6), a(12), a(14), a(18) corrected and a(31) and beyond from _Michael S. Branicky_, Dec 06 2021