login
Sum of divisors d of n with property that the binary representation of d can be obtained from the binary representation of n by changing any number of 1's to 0's.
6

%I #27 Dec 16 2022 09:00:14

%S 1,2,4,4,6,8,8,8,10,12,12,16,14,16,24,16,18,20,20,24,22,24,24,32,26,

%T 28,40,32,30,48,32,32,34,36,36,40,38,40,43,48,42,44,44,48,60,48,48,64,

%U 50,52,72,56,54,80,61,64,58,60,60,96,62,64,104,64,66,68,68,72,70,72

%N Sum of divisors d of n with property that the binary representation of d can be obtained from the binary representation of n by changing any number of 1's to 0's.

%C Equivalently, the sum of the divisors d of n such that the bitwise OR of d and n is equal to n. - _Chai Wah Wu_, Sep 06 2014

%C Equivalently, the sum of the divisors d of n such that the bitwise AND of n and d is equal to d. - _Amiram Eldar_, Dec 15 2022

%H N. J. A. Sloane, <a href="/A246601/b246601.txt">Table of n, a(n) for n = 1..10000</a>

%F a(2^i) = 2^i.

%F a(odd prime p) = p+1.

%F From _Amiram Eldar_, Dec 15 2022: (Start)

%F a(2*n) = 2*a(n), and therefore a(m*2^k) = 2^k*a(m) for m odd and k>=0.

%F a(2^n-1) = sigma(2^n-1) = A075708(n). (End)

%e 12 = 1100_2; only the divisors 4 = 0100_2 and 12 = 1100_2 satisfy the condition, so(12) = 4+12 = 16.

%e 15 = 1111_2; all divisors 1,3,5,15 satisfy the condition, so a(15)=24.

%p with(numtheory);

%p sd:=proc(n) local a,d,s,t,i,sw;

%p s:=convert(n,base,2);

%p a:=0;

%p for d in divisors(n) do

%p sw:=-1;

%p t:=convert(d,base,2);

%p for i from 1 to nops(t) do if t[i]>s[i] then sw:=1; fi; od:

%p if sw<0 then a:=a+d; fi;

%p od;

%p a;

%p end;

%p [seq(sd(n),n=1..100)];

%t a[n_] := DivisorSum[n, #*Boole[BitOr[#, n] == n] &]; Array[a, 100] (* _Jean-François Alcover_, Dec 02 2015, adapted from PARI *)

%o (Python)

%o from sympy import divisors

%o def A246601(n):

%o ....return sum(d for d in divisors(n) if n|d == n)

%o # _Chai Wah Wu_, Sep 06 2014

%o (PARI) a(n) = sumdiv(n, d, d*(bitor(n,d)==n)); \\ _Michel Marcus_, Sep 07 2014

%Y Cf. A000005, A000203, A075708, A246600.

%K nonn,base

%O 1,2

%A _N. J. A. Sloane_, Sep 06 2014