A154701 Numbers k such that k, k + 1 and k + 2 are 3 consecutive Harshad numbers.
1, 2, 3, 4, 5, 6, 7, 8, 110, 510, 511, 1010, 1014, 1015, 2022, 2023, 2464, 3030, 3031, 4912, 5054, 5831, 7360, 8203, 9854, 10010, 10094, 10307, 10308, 11645, 12102, 12103, 12255, 12256, 13110, 13111, 13116, 13880, 14704, 15134, 17152, 17575, 18238, 19600, 19682
Offset: 1
Examples
110 is a term since 110 is divisible by 1 + 1 + 0 = 2, 111 is divisible by 1 + 1 + 1 = 3, and 112 is divisible by 1 + 1 + 2 = 4.
References
- Jean-Marie De Koninck, Those Fascinating Numbers, American Mathematical Society, 2009, p. 36, entry 110.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
- Curtis Cooper and Robert E. Kennedy, On consecutive Niven numbers, Fibonacci Quarterly, Vol. 21, No. 2 (1993), pp. 146-151.
- Helen G. Grundman, Sequences of consecutive Niven numbers, Fibonacci Quarterly, Vol. 32, No. 2 (1994), pp. 174-175.
- Wikipedia, Harshad number
- Brad Wilson, Construction of 2n consecutive n-Niven numbers, Fibonacci Quarterly, Vol. 35, No. 2 (1997), pp. 122-128.
Crossrefs
Programs
-
C
#include
#include int is_harshad(int n){ int i,j,count=0; i=n; while(i>0){ count=count+i%10; i=i/10; } return n%count==0?1:0; } main(){ int k; clrscr(); for(k=1;k<=30000;k++) if(is_harshad(k)&&is_harshad(k+1)&&is_harshad(k+2)) printf("%d,",k); getch(); return 0; } -
Magma
f:=func
; a:=[]; for k in [1..20000] do if forall{m:m in [0..2]|f(k+m)} then Append(~a,k); end if; end for; a; // Marius A. Burtea, Jan 03 2020 -
Maple
Res:= NULL: count:= 0: state:= 1: L:= [1]: for n from 2 while count < 100 do L[1]:=L[1]+1; for k from 1 while L[k]=10 do L[k]:= 0; if k = nops(L) then L:= [0$nops(L),1]; break else L[k+1]:= L[k+1]+1 fi od: s:= convert(L,`+`); if n mod s = 0 then state:= min(state+1,3); if state = 3 then count:= count+1; Res:= Res, n-2; fi else state:= 0 fi od: Res; # Robert Israel, Feb 01 2019
-
Mathematica
nivenQ[n_] := Divisible[n, Total @ IntegerDigits[n]]; niv = nivenQ /@ Range[3]; seq = {}; Do[niv = Join[Rest[niv], {nivenQ[k]}]; If[And @@ niv, AppendTo[seq, k - 2]], {k, 3, 2*10^4}]; seq (* Amiram Eldar, Jan 03 2020 *)
-
Python
from itertools import count, islice def agen(): # generator of terms h1, h2, h3 = 1, 2, 3 while True: if h3 - h1 == 2: yield h1 h1, h2, h3 = h2, h3, next(k for k in count(h3+1) if k%sum(map(int, str(k))) == 0) print(list(islice(agen(), 45))) # Michael S. Branicky, Mar 17 2024
Comments