Determine the sum of all possible values of a six digit (non leading zero) even number N that uses only the digits 0, 1, 2, 3, 4, 5.
- All the six digits may not appear in N, so that 543210 is NOT a valid entry.
- Some of these six digits can be repeated more than once in N.
First, the computed result (code below) is 6269585184
Analytic estimate
The total ways to choose such a number is 5*6*6*6*6*3 = 19440, but then we must subtract the number of these which have no repeat digits.
That would be 5*5*4*3*2*1 = 600 if evens and odds were both allowed, so 300 of these would be even.
We have 19440 - 300 = 19140 ways.
Determine, for each digit position what the average digit size is.
Do this if no repeat digits is allowed; and also for the no repeat digits group.
1st group (allowing "all unique digits") average digit going from left to right:
3, 2.5, 2.5, 2.5, 2.5, 2
Multiplying each of these by the appropriate power of 10 and summing: 327777
This would be the average size of N (if no repeat digits were allowed)
A similar analysis for six digit pandigitals (0...5) which are even hits a snag because constraining the last digit to be even, throws off the probabilities for the other digits: they are less likely to be even than they would be if the "even" constraint was not there. One could figure it out without the even constraint, then divide by 2 and this would be pretty close, so lets do that.
2nd group: 6 digit pandigitals (0...5), ie all unique digits, including evens AND odds, average digits are:
3, 2.5, 2.5, 2.5, 2.5, 2.5
Now the average group 2 number is 327777.5 and there would be 600 of them (5*5*4*3*2*1) if evens and odds were both allowed. So 327777.5 * 300 should be close: 98333250
Multiplying 327777 (which is not accurate) by 19440 and then subtracting 327777.5 * 300 should give a rough estimate of the answer:
6273651630 is the rough estimate
6269585184 is the computed answer
Sources for error in the rough estimate:
Constraining the last digit to be even tweaks the probabilities of being even for the first 5 digits.
The sum of all even 6-digit pandigitals (0...5) is probably not exactly 1/2 of the sum of all the evens plus the odds.
Summary: 1.5 cheers for an analytic estimate in the right ballpark, but acknowledge a failure of obtaining an accurate analytic solution.
--------------------------------
bigsum = 0
for a in range(1,6):
for b in range(0,6):
for c in range(0,6):
for d in range(0,6):
for e in range(0,6):
for f in range(0,6,2):
if len(set([a,b,c,d,e,f])) == 6:
continue
littlesum = f+e*10+d*100+c*1000+b*10000+a*100000
bigsum += littlesum
print(bigsum)
Edited on August 22, 2023, 2:13 pm
|
Posted by Larry
on 2023-08-22 14:09:31 |