OFFSET
1,2
COMMENTS
Cai proved that there are infinitely many runs of 4 consecutive Niven numbers in base 2. Therefore this sequence is infinite.
REFERENCES
József Sándor and Borislav Crstici, Handbook of Number theory II, Kluwer Academic Publishers, 2004, Chapter 4, p. 382.
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000
Tianxin Cai, On 2-Niven numbers and 3-Niven numbers, Fibonacci Quarterly, Vol. 34, No. 2 (1996), pp. 118-120.
Wikipedia, Harshad number.
Brad Wilson, Construction of 2n consecutive n-Niven numbers, Fibonacci Quarterly, Vol. 35, No. 2 (1997), pp. 122-128.
EXAMPLE
20 is a term since 20 and 20 + 1 = 21 are both Niven numbers in base 2.
MATHEMATICA
binNivenQ[n_] := Divisible[n, Total @ IntegerDigits[n, 2]]; bnq1 = binNivenQ[1]; seq = {}; Do[bnq2 = binNivenQ[k]; If[bnq1 && bnq2, AppendTo[seq, k - 1]]; bnq1 = bnq2, {k, 2, 10^4}]; seq
PROG
(Magma) f:=func<n|n mod &+Intseq(n, 2) eq 0>; a:=[]; for k in [1..1500] do if forall{m:m in [0..1]|f(k+m)} then Append(~a, k); end if; end for; a; // Marius A. Burtea, Jan 03 2020
(Python)
def sbd(n): return sum(map(int, str(bin(n)[2:])))
def niv2(n): return n%sbd(n) == 0
def aupto(nn): return [k for k in range(1, nn+1) if niv2(k) and niv2(k+1)]
print(aupto(1424)) # Michael S. Branicky, Jan 20 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Amiram Eldar, Jan 03 2020
STATUS
approved