|
|
A061384
|
|
Numbers n such that sum of digits = number of digits.
|
|
16
|
|
|
1, 11, 20, 102, 111, 120, 201, 210, 300, 1003, 1012, 1021, 1030, 1102, 1111, 1120, 1201, 1210, 1300, 2002, 2011, 2020, 2101, 2110, 2200, 3001, 3010, 3100, 4000, 10004, 10013, 10022, 10031, 10040, 10103, 10112, 10121, 10130, 10202, 10211
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
Equivalently, numbers n > 0 for which the arithmetic mean of the digits equals 1. - M. F. Hasler, Dec 07 2018
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
120 is a term as the arithmetic mean of the digits is (1+2+0)/3 = 1.
|
|
MAPLE
|
Q:= proc(n, s) option remember;
# n-digit integers with digit sum s
if s = 0 then []
elif s = 1 then [10^(n-1)]
elif n = 1 then
if s <= 9 then [s]
else []
fi
else
map(op, [seq(map(t -> 10*t+i, procname(n-1, s-i)), i=0..min(9, s-1))])
fi
end proc:
map(op, [seq(sort(Q(n, n)), n=1..5)]); # Robert Israel, Apr 06 2016
|
|
MATHEMATICA
|
Select[Range[15000], Total[IntegerDigits[#]] == IntegerLength[#]&] (* Harvey P. Dale, Jan 08 2011 *)
|
|
PROG
|
(Magma) [ n: n in [1..10215] | &+Intseq(n) eq #Intseq(n) ]; // Bruno Berselli, Jun 30 2011
(PARI) isok(n) = (sumdigits(n)/#Str(n) == 1); \\ Michel Marcus, Mar 28 2016
(PARI) A061384_row(n)={my(L=List(), u=vector(n, i, i==1), d); forvec(v=vector(n+1, i, [if(i>n, n, 1), if(i>1, n, 1)]), vecmax(d=v[^1]-v[^-1]+u)<10 && listput(L, fromdigits(d)), 1); Vec(L)} \\ Return the list of all n-digit terms. - M. F. Hasler, Dec 07 2018
(Python)
from itertools import count, islice
def Q(n, s): # length-n strings of 0..9 with sum s, after Robert Israel
if s == 0: yield "0"*n
elif n == 1: yield (str(s) if s <= 9 else "")
else:
m = min(9, s) + 1
yield from (str(i)+t for i in range(m) for t in Q(n-1, s-i))
def agen():
yield from (int(t) for n in count(1) for t in Q(n, n) if t[0] != "0")
(Python)
from itertools import count, islice
from collections import Counter
from sympy.utilities.iterables import partitions, multiset_permutations
def A061384_gen(): # generator of terms
for l in count(1):
for i in range(1, min(l, 9)+1):
yield from sorted(int(str(i)+''.join(map(str, j))) for s, p in partitions(l-i, k=9, size=True) for j in multiset_permutations([0]*(l-1-s)+list(Counter(p).elements())))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,easy
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|