login
Numbers that are divisible by the first, i.e., the leftmost, digit.
20

%I #43 May 01 2023 19:33:54

%S 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,24,26,28,30,33,

%T 36,39,40,44,48,50,55,60,66,70,77,80,88,90,99,100,101,102,103,104,105,

%U 106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122

%N Numbers that are divisible by the first, i.e., the leftmost, digit.

%C A 10-automatic sequence. - _Charles R Greathouse IV_, Jun 13 2017

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

%H <a href="/index/Ar#10-automatic">Index entries for 10-automatic sequences</a>.

%F a(n) mod A000030(a(n)) = 0. - _Reinhard Zumkeller_, Sep 20 2003

%t Select[Range[150],Divisible[#,IntegerDigits[#][[1]]]&] (* _Harvey P. Dale_, Jul 11 2017 *)

%o (Haskell)

%o import Data.Char (digitToInt)

%o a034837 n = a034837_list !! (n-1)

%o a034837_list = filter (\i -> i `mod` (a000030 i) == 0) [1..]

%o -- _Reinhard Zumkeller_, Jun 19 2011

%o (PARI) for(n=1,1000,n%(Vecsmall(Str(n))[1]-48) || print1(n",")) \\ _M. F. Hasler_, Jun 19 2011

%o (PARI) a(n)=for(k=1,1e9,k%(Vecsmall(Str(k))[1]-48) || n-- || return(k)) \\ _M. F. Hasler_, Jun 19 2011

%o (Python)

%o def ok(n): return n and n%int(str(n)[0]) == 0

%o print([k for k in range(123) if ok(k)]) # _Michael S. Branicky_, Jan 15 2023

%o (Python)

%o from itertools import count, islice

%o def agen(): # generator of terms

%o yield from (i for e in count(0) for f in range(1, 10) for i in range(f*10**e, (f+1)*10**e, f))

%o print(list(islice(agen(), 64))) # _Michael S. Branicky_, Jan 15 2023

%Y Cf. A034709 (divisible by last digit).

%K nonn,base,nice,look,easy

%O 1,2

%A _Erich Friedman_

%E Definition clarified by _Harvey P. Dale_, May 01 2023