# [seqfan] Re: DigitMean of a(n)

David Wilson davidwwilson at comcast.net
Sun May 10 15:34:47 CEST 2015

```There's a fairly fast way to compute these.

As is my custom, let's call one these interesting numbers a "good number".
Let good number v have d digits with sum s.
Since v is a d-digit number, we have 10^(d-1) <= v < 10^d.
Since v is good number, we have v = [10^k * (s/d)].

Thus 10^(d-1) <= [10^k * (s/d)] < 10^d.
Only one value of k satisfies this inequality, namely k = ceil((d-1)/log10(s/d)).
Hence we have v = [10^ceil((d-1)/log10(s/d)) * (s/d)].
If the sum of digits of v is indeed s, then this v is the unique good number with d digits and digits sum s, else there is no such number.

So here is a way to generate these numbers quickly (forgive my C++)

// For each number of digits
for (d = 1; ; ++d)
{
// For each possible digit sum of a d-digit number
for (s = 1; s <= 9*d; ++s)
{
// Set v to only possible good number with d digits and digit sum s.
v = [10^ceil((d-1)/log10(s/d)) * (s/d)];

// If v is indeed good, print it
If (sum of digits of v is s)
print v;
}
}

For accuracy, the log10() in has to be computed to more than d digits.
Some clever integer arithmetic could be used to compute v without using log10.

> -----Original Message-----
> From: SeqFan [mailto:seqfan-bounces at list.seqfan.eu] On Behalf Of Vladimir
> Shevelev
> Sent: Sunday, May 10, 2015 3:46 AM
> To: Sequence Fanatics Discussion list
> Subject: [seqfan] Re: DigitMean of a(n)
>
> Definitely there are infinitely many such numbers N:
> 1500, 15100, 151100, 1511100,....,
> or
> 18000,181000,1811000,18111000,...
>
> Best regards,
>
> ________________________________________
> From: SeqFan [seqfan-bounces at list.seqfan.eu] on behalf of Eric Angelini
> [Eric.Angelini at kntv.be]
> Sent: 09 May 2015 20:35
> To: Sequence Discussion list
> Subject: [seqfan] DigitMean of a(n)
>
> Hello SeqFans,
> Let's say that the "DigitMean" of a(n)
> is the sum of the digits of a(n) divided by the quantity of digits in a(n).
>
> Example: 2015 has DigitMean = 2
> because (2+0+1+5)/4 = 2.
>
> We could look for integers N such
> that DigitMean(N) _starts_ with the
> digits of N:
>
> 45, for example, has DM = 4,5
> 566 has DM = 5.66666...
> 1500 has DM = 1.500
> 2250 has DM = 2.250
> 3750 has DM = 3.750
> 18000 has DM = 1.8000
> 383333 has DM = 3.83333...
> 4428571 has DM = 4.428571...
> ...
> I guess there are infinitely more
> such integers, but their length
> increases very quick...
>
> Best,
> É.
>
>
>
>
> Catapulté de mon aPhone
>
> _______________________________________________
>
> Seqfan Mailing list - http://list.seqfan.eu/
>
> _______________________________________________
>
> Seqfan Mailing list - http://list.seqfan.eu/

```