A355593 a(n) is the number of alternating integers that divide n.
1, 2, 2, 3, 2, 4, 2, 4, 3, 4, 1, 6, 1, 4, 3, 5, 1, 6, 1, 5, 4, 2, 2, 7, 3, 2, 4, 5, 2, 7, 1, 6, 2, 3, 3, 9, 1, 3, 2, 6, 2, 7, 2, 3, 5, 3, 2, 8, 3, 6, 2, 4, 1, 8, 2, 7, 2, 4, 1, 9, 2, 2, 6, 6, 3, 4, 2, 4, 4, 7, 1, 11, 1, 3, 4, 5, 2, 5, 1, 7, 5, 3, 2, 9, 3, 3, 4, 4, 2, 11, 2, 5, 2, 4, 2, 10, 1, 6, 3, 7
Offset: 1
Examples
40 has 8 divisors: {1, 2, 4, 5, 8, 10, 20, 40} of which 2 are not alternating integers: {20, 40}, hence a(40) = 8 - 2 = 6.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
Crossrefs
Programs
-
Maple
Alt:= [$1..9, seq(seq(10*i+r - (i mod 2), r=[1,3,5,7,9]),i=1..9)]: V:= Vector(100): for t in Alt do J:= [seq(i,i=t..100,t)]; V[J]:= V[J] +~ 1 od: convert(V,list); # Robert Israel, Nov 26 2023
-
Mathematica
q[n_] := !MemberQ[Differences[Mod[IntegerDigits[n], 2]], 0]; a[n_] := DivisorSum[n, 1 &, q[#] &]; Array[a, 120] (* Amiram Eldar, Jul 08 2022 *)
-
PARI
alternate(n,d=digits(n))=for(i=2,#d, if((d[i]-d[i-1])%2==0, return(0))); 1 a(n)=sumdiv(n,d,alternate(d)) \\ Charles R Greathouse IV, Jul 08 2022
-
Python
from sympy import divisors def p(d): return 0 if d in "02468" else 1 def c(n): if n < 10: return True s = str(n) return all(p(s[i]) != p(s[i+1]) for i in range(len(s)-1)) def a(n): return sum(1 for d in divisors(n, generator=True) if c(d)) print([a(n) for n in range(1, 101)]) # Michael S. Branicky, Jul 08 2022
Formula
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = Sum_{n>=2} 1/A030141(n) = 5.1... (the sums up to 10^10, 10^11 and 10^12 are 5.1704..., 5.1727... and 5.1738..., respectively). - Amiram Eldar, Jan 06 2024
Comments