A337819 a(n) is the smallest number k for which k*d is a Niven number, for any divisor d of n, n >= 1.
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 9, 3, 2, 3, 6, 1, 6, 1, 1, 10, 9, 1, 2, 9, 1, 3, 9, 2, 12, 9, 10, 6, 6, 1, 3, 6, 9, 1, 10, 3, 12, 10, 2, 9, 9, 3, 9, 2, 6, 9, 18, 1, 10, 9, 6, 9, 9, 2, 12, 18, 1, 9, 12, 10, 3, 6, 9, 6, 18, 1, 7, 3, 2, 9, 10, 9, 9, 9, 1, 10
Offset: 1
Examples
The numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 are in A337741, so a(1) = a(2) = ... = a(9) = a(10) = 1. For n = 11 the divisors are 1, 11 and 10 * 1 = 10 = A005349(10) and 10 * 11 = 110 = A005349(36), so a(11) = 10. For n = 14 the divisors are 1, 2, 7, 14 and 3 * 1 = 3 = A005349(3), 3 * 2 = 6 = A005349(6), 3 * 7 = 21 = A005349(14), 3 * 14 = 42 = A005349(20), so a(14) = 3. For n = 40 , A337741(18) = 40, so a(40) = 1.
Programs
-
Magma
niven:=func
; a:=[]; for n in [1..90] do k:=1; while not forall{d: d in Divisors(n)| niven(k*d)} do k:=k+1; end while; Append(~a,k); end for; a; -
Mathematica
nivenQ[n_] := Divisible[n, Plus @@ IntegerDigits[n]]; a[n_] := Module[{k = 1}, While[!AllTrue[k * Divisors[n], nivenQ], k++]; k]; Array[a, 100] (* Amiram Eldar, Sep 23 2020 *)
-
PARI
is(n) = n%sumdigits(n)==0; \\ A005349 isok(n, k) = fordiv(n, d, if (!is(k*d), return(0))); return(1); a(n) = {my(k=1); while (! isok(n,k), k++); k;} \\ Michel Marcus, Sep 24 2020
Comments