OFFSET
1,2
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
Rémy Sigrist, Colored scatterplot of the first 100000 terms (the color is function of the 2-adic valuation of n)
FORMULA
a(n) <= A000203(n).
a(2^n) = 2^(n+1) - 1 for any n >= 0.
EXAMPLE
For n = 84:
- the binary expansion of 84 is "1010100",
- we have the following divisors:
d bin(d) in bin(84)?
-- ------- -----------
1 1 Yes
2 10 Yes
3 11 No
4 100 Yes
6 110 No
7 111 No
12 1100 No
14 1110 No
21 10101 Yes
28 11100 No
42 101010 Yes
84 1010100 Yes
- so a(84) = 1 + 2 + 4 + 21 + 42 + 84 = 154.
MATHEMATICA
a[n_] := DivisorSum[n, # &, StringContainsQ @@ IntegerString[{n, #}, 2] &]; Array[a, 100] (* Amiram Eldar, Jul 16 2022 *)
PROG
(PARI) a(n, base=2) = { my (d=digits(n, base), s=setbinop((i, j) -> fromdigits(d[i..j], base), [1..#d]), v=0); for (k=1, #s, if (s[k] && n%s[k]==0, v+=s[k])); return (v) }
(Python)
from sympy import divisors
def a(n):
s = bin(n)[2:]
return sum(d for d in divisors(n, generator=True) if bin(d)[2:] in s)
print([a(n) for n in range(1, 66)]) # Michael S. Branicky, Jul 11 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jul 11 2022
STATUS
approved