OFFSET
1,2
COMMENTS
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
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
EXAMPLE
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.
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 *)
PROG
(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
(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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bernard Schott, Jul 08 2022
STATUS
approved