cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A154701 Numbers k such that k, k + 1 and k + 2 are 3 consecutive Harshad numbers.

This page as a plain text file.
%I A154701 #22 Jan 05 2025 19:51:39
%S A154701 1,2,3,4,5,6,7,8,110,510,511,1010,1014,1015,2022,2023,2464,3030,3031,
%T A154701 4912,5054,5831,7360,8203,9854,10010,10094,10307,10308,11645,12102,
%U A154701 12103,12255,12256,13110,13111,13116,13880,14704,15134,17152,17575,18238,19600,19682
%N A154701 Numbers k such that k, k + 1 and k + 2 are 3 consecutive Harshad numbers.
%C A154701 Harshad numbers are also known as Niven numbers.
%C A154701 Cooper and Kennedy proved that there are infinitely many runs of 20 consecutive Niven numbers. Therefore this sequence is infinite. - _Amiram Eldar_, Jan 03 2020
%D A154701 Jean-Marie De Koninck, Those Fascinating Numbers, American Mathematical Society, 2009, p. 36, entry 110.
%H A154701 Robert Israel, <a href="/A154701/b154701.txt">Table of n, a(n) for n = 1..10000</a>
%H A154701 Curtis Cooper and Robert E. Kennedy, <a href="https://web.archive.org/web/2024*/https://www.fq.math.ca/Scanned/31-2/cooper.pdf">On consecutive Niven numbers</a>, Fibonacci Quarterly, Vol. 21, No. 2 (1993), pp. 146-151.
%H A154701 Helen G. Grundman, <a href="https://web.archive.org/web/2024*/https://www.fq.math.ca/Scanned/32-2/grundman.pdf">Sequences of consecutive Niven numbers</a>, Fibonacci Quarterly, Vol. 32, No. 2 (1994), pp. 174-175.
%H A154701 Wikipedia, <a href="http://en.wikipedia.org/wiki/Harshad_number">Harshad number</a>
%H A154701 Brad Wilson, <a href="https://web.archive.org/web/2024*/https://www.fq.math.ca/Scanned/35-2/wilson.pdf">Construction of 2n consecutive n-Niven numbers</a>, Fibonacci Quarterly, Vol. 35, No. 2 (1997), pp. 122-128.
%e A154701 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.
%p A154701 Res:= NULL: count:= 0:
%p A154701 state:= 1:
%p A154701 L:= [1]:
%p A154701 for n from 2 while count < 100 do
%p A154701   L[1]:=L[1]+1;
%p A154701   for k from 1 while L[k]=10 do L[k]:= 0;
%p A154701     if k = nops(L) then L:= [0$nops(L),1]; break
%p A154701     else L[k+1]:= L[k+1]+1 fi
%p A154701   od:
%p A154701   s:= convert(L,`+`);
%p A154701   if n mod s = 0 then
%p A154701      state:= min(state+1,3);
%p A154701      if state = 3 then count:= count+1; Res:= Res, n-2; fi
%p A154701   else state:= 0
%p A154701   fi
%p A154701 od:
%p A154701 Res; # _Robert Israel_, Feb 01 2019
%t A154701 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 *)
%o A154701 (C) #include <stdio.h>
%o A154701 #include <conio.h>
%o A154701 int is_harshad(int n){
%o A154701   int i,j,count=0;
%o A154701   i=n;
%o A154701   while(i>0){
%o A154701     count=count+i%10;
%o A154701     i=i/10;
%o A154701   }
%o A154701   return n%count==0?1:0;
%o A154701 }
%o A154701 main(){
%o A154701   int k;
%o A154701   clrscr();
%o A154701   for(k=1;k<=30000;k++)
%o A154701     if(is_harshad(k)&&is_harshad(k+1)&&is_harshad(k+2))
%o A154701       printf("%d,",k);
%o A154701   getch();
%o A154701   return 0;
%o A154701 }
%o A154701 (Magma) f:=func<n|n mod &+Intseq(n) eq 0>; 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
%o A154701 (Python)
%o A154701 from itertools import count, islice
%o A154701 def agen(): # generator of terms
%o A154701     h1, h2, h3 = 1, 2, 3
%o A154701     while True:
%o A154701         if h3 - h1 == 2: yield h1
%o A154701         h1, h2, h3 = h2, h3, next(k for k in count(h3+1) if k%sum(map(int, str(k))) == 0)
%o A154701 print(list(islice(agen(), 45))) # _Michael S. Branicky_, Mar 17 2024
%Y A154701 A subset of A005349.
%Y A154701 Cf. A060159, A141769, A328210, A328214, A330927, A330928, A330929, A330930, A330932.
%K A154701 nonn,base
%O A154701 1,2
%A A154701 Avik Roy (avik_3.1416(AT)yahoo.co.in), Jan 14 2009, Jan 15 2009