A348318 Number of n-digit Niven (or Harshad) numbers not containing the digit 0.
9, 14, 108, 710, 4978, 35724, 273032, 2097356, 16674554, 135091242, 1112325268, 9296413365, 77991481271, 654495034497, 5420117473932
Offset: 1
Examples
a(2) = 14 because there are 14 integers {12, 18, 21, 24, 27, 36, 42, 45, 48, 54, 63, 72, 81, 84} in the set of Niven numbers with 2 digits and not containing the digit 0.
Links
- Diophante, Bon souvenir de Buenos-Aires.
- John Scholes, 39th IMO 1998 shortlisted problems, problem N7.
- Index to sequences related to Olympiads.
Programs
-
Mathematica
q[n_] := ! MemberQ[(d = IntegerDigits[n]), 0] && Divisible[n, Plus @@ d]; a[n_] := Module[{c = 0, k = (10^n - 1)/9}, While[k < 10^n, If[q[k], c++]; k++]; c]; Array[a, 6] (* Amiram Eldar, Oct 17 2021 *)
-
Python
from itertools import product def a(n): return sum(1 for p in product("123456789", repeat=n) if int("".join(p))%sum(map(int, p)) == 0) print([a(n) for n in range(1, 8)]) # Michael S. Branicky, Oct 17 2021
Extensions
a(6)-a(10) from Amiram Eldar, Oct 17 2021
a(11)-a(15) from Martin Ehrenstein, Oct 22 2021
Comments