[go: up one dir, main page]

login
A348316
a(n) is the largest Niven (or Harshad) number with exactly n digits and not containing the digit 0.
3
9, 84, 999, 9963, 99972, 999984, 9999966, 99999966, 999999999, 9999999828, 99999999898, 999999999853, 9999999999936, 99999999999783, 999999999999984, 9999999999999858, 99999999999999939, 999999999999999831, 9999999999999999951, 99999999999999999922, 999999999999999999687
OFFSET
1,1
COMMENTS
This sequence is inspired by a problem, proposed by Argentina during the 39th International Mathematical Olympiad in 1998 at Taipei, Taiwan, but not used for the competition.
The problem asked for a proof that, for each positive integer n, there exists a n-digit number, not containing the digit 0 and that is divisible by the sum of its digits (see links: Diophante in French and Kalva in English).
This sequence lists the largest such n-digit integer.
FORMULA
a(n) = A002283(n) = 10^n - 1 iff n is in A014950 (compare with A348150 formula).
EXAMPLE
9963 has 4 digits, does not contain 0 and is divisible by 9+9+6+3 = 27 (9963 = 27*369), while there is no integer k with 9964 <= k <= 9999 that is divisible by sum of its digits, hence a(4) = 9963.
MATHEMATICA
hQ[n_] := ! MemberQ[(d = IntegerDigits[n]), 0] && Divisible[n, Plus @@ d]; a[n_] := Module[{k = 10^n}, While[! hQ[k], k--]; k]; Array[a, 20] (* Amiram Eldar, Oct 11 2021 *)
PROG
(Python)
def a(n):
s, k = "9"*n, int("9"*n)
while '0' in s or k%sum(map(int, s)): k -= 1; s = str(k)
return k
print([a(n) for n in range(1, 22)]) # Michael S. Branicky, Oct 11 2021
KEYWORD
nonn,base
AUTHOR
Bernard Schott, Oct 11 2021
EXTENSIONS
More terms from Amiram Eldar, Oct 11 2021
STATUS
approved