Count Me II

How many positive integers less than 20180 have a digit sum of 18?

See related problem here .


The answer is 1335.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

X X
Apr 7, 2018

Define N ( a , b , c , . . . ) N(a,b,c,...) is the amount of possibilities of the number pair ( a , b , c , . . . ) (a,b,c,...)
Let the number be A B C D E \overline{ABCDE} (any digit can be 0)
When A = 0 A=0 ,consider ( B + C ) + ( D + E ) = 18 (B+C)+(D+E)=18
If B + C = 0 , D + E = 18 B+C=0,D+E=18 ,then N ( B , C ) = 1 , N ( D , E ) = 1 N(B,C)=1,N(D,E)=1 ,so N ( B , C , D , E ) = 1 N(B,C,D,E)=1
If B + C = 1 , D + E = 17 B+C=1,D+E=17 ,then N ( B , C ) = 2 , N ( D , E ) = 2 N(B,C)=2,N(D,E)=2 ,so N ( B , C , D , E ) = 4 N(B,C,D,E)=4
If B + C = 2 , D + E = 16 B+C=2,D+E=16 ,then N ( B , C ) = 3 , N ( D , E ) = 3 N(B,C)=3,N(D,E)=3 ,so N ( B , C , D , E ) = 9 N(B,C,D,E)=9
...
If B + C = 9 , D + E = 9 B+C=9,D+E=9 ,then N ( B , C ) = 10 , N ( D , E ) = 10 N(B,C)=10,N(D,E)=10 ,so N ( B , C , D , E ) = 100 N(B,C,D,E)=100
If B + C = 10 , D + E = 8 B+C=10,D+E=8 ,then N ( B , C ) = 9 , N ( D , E ) = 9 N(B,C)=9,N(D,E)=9 ,so N ( B , C , D , E ) = 81 N(B,C,D,E)=81
...
If B + C = 18 , D + E = 0 B+C=18,D+E=0 ,then N ( B , C ) = 1 , N ( D , E ) = 1 N(B,C)=1,N(D,E)=1 ,so N ( B , C , D , E ) = 1 N(B,C,D,E)=1
So,when A = 0 , N ( B , C , D , E ) = 1 + 4 + 9 + . . . + 100 + 81 + 64 + . . . + 4 + 1 = 670 A=0,N(B,C,D,E)=1+4+9+...+100+81+64+...+4+1=670

When A = 1 A=1 ,consider ( B + C ) + ( D + E ) = 17 (B+C)+(D+E)=17
If B + C = 0 , D + E = 17 B+C=0,D+E=17 ,then N ( B , C ) = 1 , N ( D , E ) = 2 N(B,C)=1,N(D,E)=2 ,so N ( B , C , D , E ) = 2 N(B,C,D,E)=2
If B + C = 1 , D + E = 16 B+C=1,D+E=16 ,then N ( B , C ) = 2 , N ( D , E ) = 3 N(B,C)=2,N(D,E)=3 ,so N ( B , C , D , E ) = 6 N(B,C,D,E)=6
If B + C = 2 , D + E = 15 B+C=2,D+E=15 ,then N ( B , C ) = 3 , N ( D , E ) = 4 N(B,C)=3,N(D,E)=4 ,so N ( B , C , D , E ) = 12 N(B,C,D,E)=12
...
If B + C = 8 , D + E = 9 B+C=8,D+E=9 ,then N ( B , C ) = 9 , N ( D , E ) = 10 N(B,C)=9,N(D,E)=10 ,so N ( B , C , D , E ) = 90 N(B,C,D,E)=90
If B + C = 9 , D + E = 8 B+C=9,D+E=8 ,then N ( B , C ) = 10 , N ( D , E ) = 9 N(B,C)=10,N(D,E)=9 ,so N ( B , C , D , E ) = 90 N(B,C,D,E)=90
...
If B + C = 17 , D + E = 0 B+C=17,D+E=0 ,then N ( B , C ) = 2 , N ( D , E ) = 1 N(B,C)=2,N(D,E)=1 ,so N ( B , C , D , E ) = 2 N(B,C,D,E)=2
So,when A = 1 , N ( B , C , D , E ) = 2 ( 2 + 6 + 12 + . . . + 90 ) = 660 A=1,N(B,C,D,E)=2(2+6+12+...+90)=660

When A = 2 , A B C D E = 20079 , 20088 , 20097 , 20169 , 20178 A=2,\overline{ABCDE}=20079,20088,20097,20169,20178 (5 possibilities)
So,there are 670 + 660 + 5 = 1335 670+660+5=1335 possibilities.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...