A348316 a(n) is the largest Niven (or Harshad) number with exactly n digits and not containing the digit 0.
9, 84, 999, 9963, 99972, 999984, 9999966, 99999966, 999999999, 9999999828, 99999999898, 999999999853, 9999999999936, 99999999999783, 999999999999984, 9999999999999858, 99999999999999939, 999999999999999831, 9999999999999999951, 99999999999999999922, 999999999999999999687
Offset: 1
Examples
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.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..1000
- Diophante, Bon souvenir de Buenos-Aires.
- Kalva, 39th IMO 1998 shortlisted problems, problem N7.
- Index to sequences related to Olympiads.
Programs
-
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 *)
-
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
Extensions
More terms from Amiram Eldar, Oct 11 2021
Comments