A306520 Numbers k with property that the arithmetic mean of any subset of its digits is an integer.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 17, 19, 20, 22, 24, 26, 28, 31, 33, 35, 37, 39, 40, 42, 44, 46, 48, 51, 53, 55, 57, 59, 60, 62, 64, 66, 68, 71, 73, 75, 77, 79, 80, 82, 84, 86, 88, 91, 93, 95, 97, 99, 111, 117, 135, 153, 159, 171, 177, 195
Offset: 1
Examples
17 is in this sequence because the set of digits (1,7) has an integer average: 4. 159 and 195 are in this sequence because the sets of digits (1,5), (1,9), (5,9), and (1,5,9) all have integer averages, respectively: 3, 5, 7, and 5.
Links
- Harvey P. Dale, Table of n, a(n) for n = 1..177 (all terms up to 1 million)
Programs
-
Mathematica
Select[Range[0,200],AllTrue[Mean/@Subsets[IntegerDigits[#],{2, IntegerLength[ #]}],IntegerQ]&] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Aug 09 2020 *)
-
PARI
firstTerms_vec(n)={my(v=vector(n),c,t,w:list,h);for(i=1,+oo,w=List();forsubset(i,k,listput(w,k));listpop(w,1);forvec(j=vector(i,z,[(z==1)&&(i>1),9]),h=j[1]%2;for(l=2,#j,if((j[l]%2)!=h,next(2)));for(k=1,#w,t=vecextract(j,w[k]);if(vecsum(t)%(#w[k]),next(2)));v[c++]=fromdigits(j);if(c==n,return(v))))}
-
PARI
isok(m,{B=10})={my(w=digits(m,B));forsubset(#w,y,if(y!=Vecsmall([]),if(vecsum(vecextract(w,y))%(#y),return(0)),next));1}
Formula
Apparently a(158+n) = A010785(35+n).
Comments