login
Given a number n with k digits d_i, enumerate the positions of the digits starting from LSD = 1 to MSD = k. Sequence lists the numbers such that Sum_{i=1..k} d_i/i and Sum_{i=1..k} i/d_i are equal and integer.
1

%I #28 Jan 26 2016 14:37:20

%S 1,21,321,2612,4321,52612,54321,352342,352622,352641,354612,358312,

%T 358611,652612,654321,7352342,7352622,7352641,7354612,7358312,7358611,

%U 7652612,7654321,27155485,27351684,27353616,27355325,27457722,27457741,27655315,27851554,27953333

%N Given a number n with k digits d_i, enumerate the positions of the digits starting from LSD = 1 to MSD = k. Sequence lists the numbers such that Sum_{i=1..k} d_i/i and Sum_{i=1..k} i/d_i are equal and integer.

%C The sums for the listed terms are 1, 2, 3, 5, 4, 6, 5, 7, 7, 7, 7, 7, 7, 7, 6, 8, 8, 8, 8, 8, 8, 8, 7, 14, 13, 12, 11, 10, 10, 11, 12, 10, ...

%C 2612 is the only number where no i/d_i (or d_i/i) is ever equal to 1.

%C The b-file lists all the terms <= 10^10.

%C From 7352342 on, d_7 = 7.

%C There can't be any terms >= 10^10. For an m-digit number, if p is the largest prime <= m and p >= 11, by Bertrand's postulate the first sum has exactly one term with denominator p and can't be an integer. - _Robert Israel_, Aug 14 2015

%H Paolo P. Lava, <a href="/A260487/b260487.txt">Table of n, a(n) for n = 1..798</a>

%e For 2612 we have that 2/1 + 1/2 + 6/3 + 2/4 = 1/2 + 2/1 + 3/6 + 4/2 = 5;

%e For 358611 we have that 1/1 + 1/2 + 6/3 + 8/4 + 5/5 + 3/6 = 1/1 + 2/1 +3/6 + 4/8 + 5/5 + 6/3 = 7.

%p with(numtheory):P:=proc(q) local a,b,c,k,ok,n;

%p for n from 1 to q do a:=n; b:=0; c:=0; ok:=1;

%p for k from 1 to ilog10(n)+1 do if (a mod 10)=0 then ok:=0; break;

%p else b:=b+(a mod 10)/k; c:=c+k/(a mod 10); a:=trunc(a/10); fi; od;

%p if ok=1 then if b=c and type(b,integer) then print(n); fi; fi;

%p od; end: P(10^9);

%t fQ[n_] := Block[{a, b, d = Reverse@ IntegerDigits@ n, k = IntegerLength@ n}, a = Sum[d[[i]]/i, {i, k}]; b = Sum[i/d[[i]], {i, k}]; And[a == b, IntegerQ@ a]]; Select[Select[Range@ 100000, Last@ DigitCount@ # == 0 &], fQ] (* _Michael De Vlieger_, Aug 06 2015 *)

%o (PARI) isok(n) = my(d = digits(n)); vecmin(d) && (sd = sum(k=1, #d, d[k]/(#d-k+1))) && (denominator(sd)==1) && (sd == sum(k=1,#d, k/d[#d-k+1])); \\ _Michel Marcus_, Aug 14 2015

%Y Cf. A260274, A260275, A260385, A260386.

%K nonn,base,fini,full

%O 1,2

%A _Paolo P. Lava_, Jul 27 2015