login
Numbers whose largest decimal digit is also the initial digit.
4

%I #26 Apr 28 2016 17:47:20

%S 0,1,2,3,4,5,6,7,8,9,10,11,20,21,22,30,31,32,33,40,41,42,43,44,50,51,

%T 52,53,54,55,60,61,62,63,64,65,66,70,71,72,73,74,75,76,77,80,81,82,83,

%U 84,85,86,87,88,90,91,92,93,94,95,96,97,98,99,100,101,110,111,200,201

%N Numbers whose largest decimal digit is also the initial digit.

%C A054055(a(n)) = A000030(a(n));

%C the sequence differs from A009996, A032873 and A032907: a(66)=101 is not in A009996, a(67)=110 is not in A032873 and a(65)=100 is not in A032907.

%H Reinhard Zumkeller, <a href="/A072543/b072543.txt">Table of n, a(n) for n = 1..10000</a>

%e a(10^ 1) = 9

%e a(10^ 2) = 411

%e a(10^ 3) = 6216

%e a(10^ 4) = 73474

%e a(10^ 5) = 813826

%e a(10^ 6) = 8512170

%e a(10^ 7) = 88368780

%e a(10^ 8) = 911960211

%e a(10^ 9) = 9237655227

%e a(10^10) = 93323313303

%p for i from 1 to 10 do A[i]:= i-1 od:

%p count:= 10:

%p for i from 1 to 9 do P[i]:= [seq([j],j=0..i)]; od:

%p for d from 2 to 4 do

%p for x from 1 to 9 do

%p for p in P[x] do

%p count:= count+1;

%p A[count]:= add(p[k]*10^(k-1),k=1..d-1) + x*10^(d-1);

%p od:

%p P[x]:= [seq(seq([op(v),t], v=P[x]),t=0..x)];

%p od

%p od:

%p seq(A[i],i=1..count); # _Robert Israel_, Feb 01 2015

%t Select[Range[0,250],Max[IntegerDigits[#]]==First[IntegerDigits[#]]&] (* _Harvey P. Dale_, Apr 28 2016 *)

%o (Haskell)

%o a072543 n = a072543_list !! (n-1)

%o a072543_list = [x | x <- [0..], a054055 x == a000030 x]

%o -- _Reinhard Zumkeller_, Apr 25 2012

%o (PARI) is(n)=n=digits(n); !#n || n[1]==vecmax(n) \\ _Charles R Greathouse IV_, Jan 02 2014

%o (PARI) a(n)={d = 0; r = 1; s = 0; i = 0; if(n == 1, 0, n-=2; while(n > sum(i=0, 9,(i+1)^d), n-=sum(i=0, 9, (i+1)^d); n++; d++); while(n >= (r+1)^d, n -= (r+1)^d; r++);s = r * 10^d; while(n, s += 10^i*(n%(r+1)); n \= (r+1); i++));s } \\ _David A. Corneth_, Jan 31 2015

%Y Cf. A072544.

%K nonn,base,easy

%O 1,3

%A _Reinhard Zumkeller_, Aug 04 2002

%E Offset corrected by _Reinhard Zumkeller_, Apr 25 2012