Question and Answers Forum

All Questions      Topic List

Permutation and Combination Questions

Previous in All Question      Next in All Question      

Previous in Permutation and Combination      Next in Permutation and Combination      

Question Number 188362 by mr W last updated on 28/Feb/23

find the number of 5 digit natural  numbers with strictly ascending   digits whose sum is 20.  example: 12458 is such a number

$${find}\:{the}\:{number}\:{of}\:\mathrm{5}\:{digit}\:{natural} \\ $$$${numbers}\:{with}\:{strictly}\:{ascending}\: \\ $$$${digits}\:{whose}\:{sum}\:{is}\:\mathrm{20}. \\ $$$${example}:\:\mathrm{12458}\:{is}\:{such}\:{a}\:{number} \\ $$

Answered by ARUNG_Brandon_MBU last updated on 28/Feb/23

6

$$\mathrm{6} \\ $$

Commented by ARUNG_Brandon_MBU last updated on 28/Feb/23

#include <iostream> using namespace std; int main(void) { for (int i0, i1, i2, i3, i4, i=10000; i<100000; i++) { i0 = i/10000; i1 = i%10000/1000; i2 = i%1000/100; i3 = i%100/10; i4 = i%10; if (i0<i1 && i1<i2 && i2<i3 && i3<i4) if ((i0+i1+i2+i3+i4) == 20) cout << i <<", "; } return 0; }

Commented by ARUNG_Brandon_MBU last updated on 28/Feb/23

Output: 12359, 12368, 12458,                    12467, 13457, 23456,

$$\mathrm{Output}:\:\mathrm{12359},\:\mathrm{12368},\:\mathrm{12458}, \\ $$$$\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\mathrm{12467},\:\mathrm{13457},\:\mathrm{23456}, \\ $$

Commented by mr W last updated on 28/Feb/23

yes!

$${yes}! \\ $$

Commented by ARUNG_Brandon_MBU last updated on 28/Feb/23

��

Commented by mr W last updated on 01/Mar/23

in this case, i mean when the sum of   digits is ≤20, we can still have a   smart solution, which gives us the  answer 7−1=6.  7 is the coef. of term x^(20)  in the  expansion Π_(k=1) ^5 (x^k /(1−x^k )). but it includes  also the case that a digit is 10, which  is certainly not true, therefore the  correct answer is 7−1=6.  if the sum of digits is >20, i think  we can only enumerate all possible  possibilities as your program does.  there is no smarter approach.

$${in}\:{this}\:{case},\:{i}\:{mean}\:{when}\:{the}\:{sum}\:{of}\: \\ $$$${digits}\:{is}\:\leqslant\mathrm{20},\:{we}\:{can}\:{still}\:{have}\:{a}\: \\ $$$${smart}\:{solution},\:{which}\:{gives}\:{us}\:{the} \\ $$$${answer}\:\mathrm{7}−\mathrm{1}=\mathrm{6}. \\ $$$$\mathrm{7}\:{is}\:{the}\:{coef}.\:{of}\:{term}\:{x}^{\mathrm{20}} \:{in}\:{the} \\ $$$${expansion}\:\underset{{k}=\mathrm{1}} {\overset{\mathrm{5}} {\prod}}\frac{{x}^{{k}} }{\mathrm{1}−{x}^{{k}} }.\:{but}\:{it}\:{includes} \\ $$$${also}\:{the}\:{case}\:{that}\:{a}\:{digit}\:{is}\:\mathrm{10},\:{which} \\ $$$${is}\:{certainly}\:{not}\:{true},\:{therefore}\:{the} \\ $$$${correct}\:{answer}\:{is}\:\mathrm{7}−\mathrm{1}=\mathrm{6}. \\ $$$${if}\:{the}\:{sum}\:{of}\:{digits}\:{is}\:>\mathrm{20},\:{i}\:{think} \\ $$$${we}\:{can}\:{only}\:{enumerate}\:{all}\:{possible} \\ $$$${possibilities}\:{as}\:{your}\:{program}\:{does}. \\ $$$${there}\:{is}\:{no}\:{smarter}\:{approach}. \\ $$

Commented by ARUNG_Brandon_MBU last updated on 28/Feb/23

����

Commented by mr W last updated on 04/Mar/23

i found a new way even for n>20,  see below. can you please check with  your program?

$${i}\:{found}\:{a}\:{new}\:{way}\:{even}\:{for}\:{n}>\mathrm{20}, \\ $$$${see}\:{below}.\:{can}\:{you}\:{please}\:{check}\:{with} \\ $$$${your}\:{program}? \\ $$

Commented by ARUNG_Brandon_MBU last updated on 07/Mar/23

// for n > 20 #include <iostream> using namespace std; int main(void) { for(int i0,i1,i2,i3,i4,i=10000;i<100000;i++) { i0 = i/10000; i1 = i%10000/1000; i2 = i%1000/100; i3 = i%100/10; i4 = i%10; if (i0<i1 && i1<i2 && i2<i3 && i3<i4) if (i0+i1+i2+i3+i4 > 20) cout << i <<" "; } return 0; }

Commented by ARUNG_Brandon_MBU last updated on 07/Mar/23

Commented by ARUNG_Brandon_MBU last updated on 07/Mar/23

We have 108 5-digit numbers such that  the digits are different and their sum > 20

$$\mathrm{We}\:\mathrm{have}\:\mathrm{108}\:\mathrm{5}-\mathrm{digit}\:\mathrm{numbers}\:\mathrm{such}\:\mathrm{that} \\ $$$$\mathrm{the}\:\mathrm{digits}\:\mathrm{are}\:\mathrm{different}\:\mathrm{and}\:\mathrm{their}\:\mathrm{sum}\:>\:\mathrm{20} \\ $$

Commented by mr W last updated on 07/Mar/23

yes, that′s correct!  as we can see below there are  8 numbers with sum 21,  9 numbers with sum 22,  11 numbers with sum 23,  ...  2 numbers with sum 33,  1 number with sum 34,  1 number with sum 35.  so totally 108 numbers with sum>20.

$${yes},\:{that}'{s}\:{correct}! \\ $$$${as}\:{we}\:{can}\:{see}\:{below}\:{there}\:{are} \\ $$$$\mathrm{8}\:{numbers}\:{with}\:{sum}\:\mathrm{21}, \\ $$$$\mathrm{9}\:{numbers}\:{with}\:{sum}\:\mathrm{22}, \\ $$$$\mathrm{11}\:{numbers}\:{with}\:{sum}\:\mathrm{23}, \\ $$$$... \\ $$$$\mathrm{2}\:{numbers}\:{with}\:{sum}\:\mathrm{33}, \\ $$$$\mathrm{1}\:{number}\:{with}\:{sum}\:\mathrm{34}, \\ $$$$\mathrm{1}\:{number}\:{with}\:{sum}\:\mathrm{35}. \\ $$$${so}\:{totally}\:\mathrm{108}\:{numbers}\:{with}\:{sum}>\mathrm{20}. \\ $$

Answered by mr W last updated on 04/Mar/23

a new try  say the number is d_1 d_2 d_3 d_4 d_5  with  d_1 +d_2 +d_3 +d_4 +d_5 =n and  1≤d_1 <d_2 <d_3 <d_4 <d_5 ≤9  let   d_1 =1+k_1  with 0≤k_1 ≤8  d_2 =d_1 +1+k_2 =2+k_1 +k_2  with 0≤k_2 ≤7  d_3 =d_2 +1+k_3 =3+k_1 +k_2 +k_3  with 0≤k_3 ≤6  ......  d_5 =d_4 +1+k_4 =5+k_1 +k_2 +k_3 +...+k_5  with 0≤k_3 ≤4  (1+2+3+...+5)+5k_1 +4k_2 +3k_3 +2k_4 +k_5 =n  number of solutions is the coef. of  term x^n  in the expansion of  x^(15) Π_(r=1) ^5 ((1−x^(10−r) )/(1−x^r ))  for n=20 we have 6 numbers and  for n=25 we have 12 numbers etc.

$${a}\:{new}\:{try} \\ $$$${say}\:{the}\:{number}\:{is}\:{d}_{\mathrm{1}} {d}_{\mathrm{2}} {d}_{\mathrm{3}} {d}_{\mathrm{4}} {d}_{\mathrm{5}} \:{with} \\ $$$${d}_{\mathrm{1}} +{d}_{\mathrm{2}} +{d}_{\mathrm{3}} +{d}_{\mathrm{4}} +{d}_{\mathrm{5}} ={n}\:{and} \\ $$$$\mathrm{1}\leqslant{d}_{\mathrm{1}} <{d}_{\mathrm{2}} <{d}_{\mathrm{3}} <{d}_{\mathrm{4}} <{d}_{\mathrm{5}} \leqslant\mathrm{9} \\ $$$${let}\: \\ $$$${d}_{\mathrm{1}} =\mathrm{1}+{k}_{\mathrm{1}} \:{with}\:\mathrm{0}\leqslant{k}_{\mathrm{1}} \leqslant\mathrm{8} \\ $$$${d}_{\mathrm{2}} ={d}_{\mathrm{1}} +\mathrm{1}+{k}_{\mathrm{2}} =\mathrm{2}+{k}_{\mathrm{1}} +{k}_{\mathrm{2}} \:{with}\:\mathrm{0}\leqslant{k}_{\mathrm{2}} \leqslant\mathrm{7} \\ $$$${d}_{\mathrm{3}} ={d}_{\mathrm{2}} +\mathrm{1}+{k}_{\mathrm{3}} =\mathrm{3}+{k}_{\mathrm{1}} +{k}_{\mathrm{2}} +{k}_{\mathrm{3}} \:{with}\:\mathrm{0}\leqslant{k}_{\mathrm{3}} \leqslant\mathrm{6} \\ $$$$...... \\ $$$${d}_{\mathrm{5}} ={d}_{\mathrm{4}} +\mathrm{1}+{k}_{\mathrm{4}} =\mathrm{5}+{k}_{\mathrm{1}} +{k}_{\mathrm{2}} +{k}_{\mathrm{3}} +...+{k}_{\mathrm{5}} \:{with}\:\mathrm{0}\leqslant{k}_{\mathrm{3}} \leqslant\mathrm{4} \\ $$$$\left(\mathrm{1}+\mathrm{2}+\mathrm{3}+...+\mathrm{5}\right)+\mathrm{5}{k}_{\mathrm{1}} +\mathrm{4}{k}_{\mathrm{2}} +\mathrm{3}{k}_{\mathrm{3}} +\mathrm{2}{k}_{\mathrm{4}} +{k}_{\mathrm{5}} ={n} \\ $$$${number}\:{of}\:{solutions}\:{is}\:{the}\:{coef}.\:{of} \\ $$$${term}\:{x}^{{n}} \:{in}\:{the}\:{expansion}\:{of} \\ $$$${x}^{\mathrm{15}} \underset{{r}=\mathrm{1}} {\overset{\mathrm{5}} {\prod}}\frac{\mathrm{1}−{x}^{\mathrm{10}−{r}} }{\mathrm{1}−{x}^{{r}} } \\ $$$${for}\:{n}=\mathrm{20}\:{we}\:{have}\:\mathrm{6}\:{numbers}\:{and} \\ $$$${for}\:{n}=\mathrm{25}\:{we}\:{have}\:\mathrm{12}\:{numbers}\:{etc}. \\ $$

Commented by mr W last updated on 04/Mar/23

Commented by mr W last updated on 04/Mar/23

in case of 6 digit numbers we need  to find the coef. of term x^n  in  x^(21) Π_(r=1) ^6 ((1−x^(10−r) )/(1−x^r ))  for n=25 we have 4 numbers and  for n=30 we have 8 numbers etc.

$${in}\:{case}\:{of}\:\mathrm{6}\:{digit}\:{numbers}\:{we}\:{need} \\ $$$${to}\:{find}\:{the}\:{coef}.\:{of}\:{term}\:{x}^{{n}} \:{in} \\ $$$${x}^{\mathrm{21}} \underset{{r}=\mathrm{1}} {\overset{\mathrm{6}} {\prod}}\frac{\mathrm{1}−{x}^{\mathrm{10}−{r}} }{\mathrm{1}−{x}^{{r}} } \\ $$$${for}\:{n}=\mathrm{25}\:{we}\:{have}\:\mathrm{4}\:{numbers}\:{and} \\ $$$${for}\:{n}=\mathrm{30}\:{we}\:{have}\:\mathrm{8}\:{numbers}\:{etc}. \\ $$

Commented by mr W last updated on 04/Mar/23

Terms of Service

Privacy Policy

Contact: info@tinkutara.com