[go: up one dir, main page]

login
A348318
Number of n-digit Niven (or Harshad) numbers not containing the digit 0.
2
9, 14, 108, 710, 4978, 35724, 273032, 2097356, 16674554, 135091242, 1112325268, 9296413365, 77991481271, 654495034497, 5420117473932
OFFSET
1,1
COMMENTS
This sequence comes from a problem, proposed by Argentina during the 39th International Mathematical Olympiad in 1998 at Taipei, Taiwan, but not used for the competition. This problem asked for a proof that, for each positive integer n, there exists an n-digit number, not containing the digit 0 and that is divisible by the sum of its digits (see links: Diophante in French and Scholes in English).
This sequence gives the number of such n-digit Niven numbers not containing the digit 0.
EXAMPLE
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.
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 *)
PROG
(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
KEYWORD
nonn,base,more
AUTHOR
Bernard Schott, Oct 17 2021
EXTENSIONS
a(6)-a(10) from Amiram Eldar, Oct 17 2021
a(11)-a(15) from Martin Ehrenstein, Oct 22 2021
STATUS
approved