Number of $7$-digit positive integers with digital sum equal to $48$?












1












$begingroup$


How many $7$-digit positive integers are there with digit sum $48$? Leading zero is not allowed.



My approach : consider a number $x_1x_2x_3x_4x_5x_6x_7$ where $x_1$ isn't $0$. Now, the solution of $x_1+ dots + x_7=48$ in the set of $W$ is $C(54,6)$ where $x_1$ can be $0$ too, which we don't want and we need to get rid of the solutions starting with $0$. Number of solutions starting with $0$ of this equation : $0+x_2+x_3+ dots +x_7=48$ is $C(53,5)$, which is the number we want to get rid of from $C(54,6)$. Thus required answer would be $C(54,6)-C(53,5)$. But the answer given is way different than my one. If any, where have I went wrong?










share|cite|improve this question











$endgroup$








  • 1




    $begingroup$
    You may have included numbers where the largest digit is bigger than $9$
    $endgroup$
    – Henry
    Dec 26 '18 at 8:52










  • $begingroup$
    I have included numbers 0<=xi<=9, 1<=i<=7 for the first one I believe.
    $endgroup$
    – Epsilon zero
    Dec 26 '18 at 8:57






  • 3




    $begingroup$
    Did you exclude invalid cases like $x_1=48$?
    $endgroup$
    – drhab
    Dec 26 '18 at 9:18












  • $begingroup$
    Let me suggest "sum of digits" is more apt than "digital sum", since the latter is often used to signify the iterative process of summing digits to get a single digit (also called "casting out nines").
    $endgroup$
    – hardmath
    Dec 26 '18 at 18:08
















1












$begingroup$


How many $7$-digit positive integers are there with digit sum $48$? Leading zero is not allowed.



My approach : consider a number $x_1x_2x_3x_4x_5x_6x_7$ where $x_1$ isn't $0$. Now, the solution of $x_1+ dots + x_7=48$ in the set of $W$ is $C(54,6)$ where $x_1$ can be $0$ too, which we don't want and we need to get rid of the solutions starting with $0$. Number of solutions starting with $0$ of this equation : $0+x_2+x_3+ dots +x_7=48$ is $C(53,5)$, which is the number we want to get rid of from $C(54,6)$. Thus required answer would be $C(54,6)-C(53,5)$. But the answer given is way different than my one. If any, where have I went wrong?










share|cite|improve this question











$endgroup$








  • 1




    $begingroup$
    You may have included numbers where the largest digit is bigger than $9$
    $endgroup$
    – Henry
    Dec 26 '18 at 8:52










  • $begingroup$
    I have included numbers 0<=xi<=9, 1<=i<=7 for the first one I believe.
    $endgroup$
    – Epsilon zero
    Dec 26 '18 at 8:57






  • 3




    $begingroup$
    Did you exclude invalid cases like $x_1=48$?
    $endgroup$
    – drhab
    Dec 26 '18 at 9:18












  • $begingroup$
    Let me suggest "sum of digits" is more apt than "digital sum", since the latter is often used to signify the iterative process of summing digits to get a single digit (also called "casting out nines").
    $endgroup$
    – hardmath
    Dec 26 '18 at 18:08














1












1








1





$begingroup$


How many $7$-digit positive integers are there with digit sum $48$? Leading zero is not allowed.



My approach : consider a number $x_1x_2x_3x_4x_5x_6x_7$ where $x_1$ isn't $0$. Now, the solution of $x_1+ dots + x_7=48$ in the set of $W$ is $C(54,6)$ where $x_1$ can be $0$ too, which we don't want and we need to get rid of the solutions starting with $0$. Number of solutions starting with $0$ of this equation : $0+x_2+x_3+ dots +x_7=48$ is $C(53,5)$, which is the number we want to get rid of from $C(54,6)$. Thus required answer would be $C(54,6)-C(53,5)$. But the answer given is way different than my one. If any, where have I went wrong?










share|cite|improve this question











$endgroup$




How many $7$-digit positive integers are there with digit sum $48$? Leading zero is not allowed.



My approach : consider a number $x_1x_2x_3x_4x_5x_6x_7$ where $x_1$ isn't $0$. Now, the solution of $x_1+ dots + x_7=48$ in the set of $W$ is $C(54,6)$ where $x_1$ can be $0$ too, which we don't want and we need to get rid of the solutions starting with $0$. Number of solutions starting with $0$ of this equation : $0+x_2+x_3+ dots +x_7=48$ is $C(53,5)$, which is the number we want to get rid of from $C(54,6)$. Thus required answer would be $C(54,6)-C(53,5)$. But the answer given is way different than my one. If any, where have I went wrong?







combinatorics






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Dec 26 '18 at 10:04









N. F. Taussig

45.2k103358




45.2k103358










asked Dec 26 '18 at 8:48









Epsilon zeroEpsilon zero

34118




34118








  • 1




    $begingroup$
    You may have included numbers where the largest digit is bigger than $9$
    $endgroup$
    – Henry
    Dec 26 '18 at 8:52










  • $begingroup$
    I have included numbers 0<=xi<=9, 1<=i<=7 for the first one I believe.
    $endgroup$
    – Epsilon zero
    Dec 26 '18 at 8:57






  • 3




    $begingroup$
    Did you exclude invalid cases like $x_1=48$?
    $endgroup$
    – drhab
    Dec 26 '18 at 9:18












  • $begingroup$
    Let me suggest "sum of digits" is more apt than "digital sum", since the latter is often used to signify the iterative process of summing digits to get a single digit (also called "casting out nines").
    $endgroup$
    – hardmath
    Dec 26 '18 at 18:08














  • 1




    $begingroup$
    You may have included numbers where the largest digit is bigger than $9$
    $endgroup$
    – Henry
    Dec 26 '18 at 8:52










  • $begingroup$
    I have included numbers 0<=xi<=9, 1<=i<=7 for the first one I believe.
    $endgroup$
    – Epsilon zero
    Dec 26 '18 at 8:57






  • 3




    $begingroup$
    Did you exclude invalid cases like $x_1=48$?
    $endgroup$
    – drhab
    Dec 26 '18 at 9:18












  • $begingroup$
    Let me suggest "sum of digits" is more apt than "digital sum", since the latter is often used to signify the iterative process of summing digits to get a single digit (also called "casting out nines").
    $endgroup$
    – hardmath
    Dec 26 '18 at 18:08








1




1




$begingroup$
You may have included numbers where the largest digit is bigger than $9$
$endgroup$
– Henry
Dec 26 '18 at 8:52




$begingroup$
You may have included numbers where the largest digit is bigger than $9$
$endgroup$
– Henry
Dec 26 '18 at 8:52












$begingroup$
I have included numbers 0<=xi<=9, 1<=i<=7 for the first one I believe.
$endgroup$
– Epsilon zero
Dec 26 '18 at 8:57




$begingroup$
I have included numbers 0<=xi<=9, 1<=i<=7 for the first one I believe.
$endgroup$
– Epsilon zero
Dec 26 '18 at 8:57




3




3




$begingroup$
Did you exclude invalid cases like $x_1=48$?
$endgroup$
– drhab
Dec 26 '18 at 9:18






$begingroup$
Did you exclude invalid cases like $x_1=48$?
$endgroup$
– drhab
Dec 26 '18 at 9:18














$begingroup$
Let me suggest "sum of digits" is more apt than "digital sum", since the latter is often used to signify the iterative process of summing digits to get a single digit (also called "casting out nines").
$endgroup$
– hardmath
Dec 26 '18 at 18:08




$begingroup$
Let me suggest "sum of digits" is more apt than "digital sum", since the latter is often used to signify the iterative process of summing digits to get a single digit (also called "casting out nines").
$endgroup$
– hardmath
Dec 26 '18 at 18:08










1 Answer
1






active

oldest

votes


















1












$begingroup$

Your approach is wrong: $C(54,6)$ assumes that digitis like '32' or '15' are allowed. This is not a "stars and bars" problem.



Denote with $Z(l,s)$ the number of integers of length $l$ with sum of digits equal to $s$ assuming that leading zero is allowed.



You have the following recurrence formula:



$$Z(l,s)=sum_{d=0}^{d=9}Z(l-1,s-d)$$



...with the following exit criteria:



$$Z(1,s)=0 quad text{if} quad s<0 lor s>9$$



$$Z(1,s)=1 quad text{if}quad 0 le s le 9$$



You are actually trying to calculate $Z(7, 48)-Z(6,48)$ (this eliminates all 7-digit numbers with a leading zero):



#include <iostream>
using namespace std;

int count(int length, int sum) {
if(length == 1)
return (sum >= 0 && sum <= 9)? 1: 0;
int cnt = 0;
for(int i = 0; i <= 9; i++)
cnt += count(length - 1, sum - i);
return cnt;
}

int main() {
cout << (count(7, 48) - count(6, 48));
}


...and the result is 50568.






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Thanks a lot ! I will look into the stars and bars method again to clarify it's idea.
    $endgroup$
    – Epsilon zero
    Dec 26 '18 at 10:18












Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3052762%2fnumber-of-7-digit-positive-integers-with-digital-sum-equal-to-48%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1












$begingroup$

Your approach is wrong: $C(54,6)$ assumes that digitis like '32' or '15' are allowed. This is not a "stars and bars" problem.



Denote with $Z(l,s)$ the number of integers of length $l$ with sum of digits equal to $s$ assuming that leading zero is allowed.



You have the following recurrence formula:



$$Z(l,s)=sum_{d=0}^{d=9}Z(l-1,s-d)$$



...with the following exit criteria:



$$Z(1,s)=0 quad text{if} quad s<0 lor s>9$$



$$Z(1,s)=1 quad text{if}quad 0 le s le 9$$



You are actually trying to calculate $Z(7, 48)-Z(6,48)$ (this eliminates all 7-digit numbers with a leading zero):



#include <iostream>
using namespace std;

int count(int length, int sum) {
if(length == 1)
return (sum >= 0 && sum <= 9)? 1: 0;
int cnt = 0;
for(int i = 0; i <= 9; i++)
cnt += count(length - 1, sum - i);
return cnt;
}

int main() {
cout << (count(7, 48) - count(6, 48));
}


...and the result is 50568.






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Thanks a lot ! I will look into the stars and bars method again to clarify it's idea.
    $endgroup$
    – Epsilon zero
    Dec 26 '18 at 10:18
















1












$begingroup$

Your approach is wrong: $C(54,6)$ assumes that digitis like '32' or '15' are allowed. This is not a "stars and bars" problem.



Denote with $Z(l,s)$ the number of integers of length $l$ with sum of digits equal to $s$ assuming that leading zero is allowed.



You have the following recurrence formula:



$$Z(l,s)=sum_{d=0}^{d=9}Z(l-1,s-d)$$



...with the following exit criteria:



$$Z(1,s)=0 quad text{if} quad s<0 lor s>9$$



$$Z(1,s)=1 quad text{if}quad 0 le s le 9$$



You are actually trying to calculate $Z(7, 48)-Z(6,48)$ (this eliminates all 7-digit numbers with a leading zero):



#include <iostream>
using namespace std;

int count(int length, int sum) {
if(length == 1)
return (sum >= 0 && sum <= 9)? 1: 0;
int cnt = 0;
for(int i = 0; i <= 9; i++)
cnt += count(length - 1, sum - i);
return cnt;
}

int main() {
cout << (count(7, 48) - count(6, 48));
}


...and the result is 50568.






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Thanks a lot ! I will look into the stars and bars method again to clarify it's idea.
    $endgroup$
    – Epsilon zero
    Dec 26 '18 at 10:18














1












1








1





$begingroup$

Your approach is wrong: $C(54,6)$ assumes that digitis like '32' or '15' are allowed. This is not a "stars and bars" problem.



Denote with $Z(l,s)$ the number of integers of length $l$ with sum of digits equal to $s$ assuming that leading zero is allowed.



You have the following recurrence formula:



$$Z(l,s)=sum_{d=0}^{d=9}Z(l-1,s-d)$$



...with the following exit criteria:



$$Z(1,s)=0 quad text{if} quad s<0 lor s>9$$



$$Z(1,s)=1 quad text{if}quad 0 le s le 9$$



You are actually trying to calculate $Z(7, 48)-Z(6,48)$ (this eliminates all 7-digit numbers with a leading zero):



#include <iostream>
using namespace std;

int count(int length, int sum) {
if(length == 1)
return (sum >= 0 && sum <= 9)? 1: 0;
int cnt = 0;
for(int i = 0; i <= 9; i++)
cnt += count(length - 1, sum - i);
return cnt;
}

int main() {
cout << (count(7, 48) - count(6, 48));
}


...and the result is 50568.






share|cite|improve this answer









$endgroup$



Your approach is wrong: $C(54,6)$ assumes that digitis like '32' or '15' are allowed. This is not a "stars and bars" problem.



Denote with $Z(l,s)$ the number of integers of length $l$ with sum of digits equal to $s$ assuming that leading zero is allowed.



You have the following recurrence formula:



$$Z(l,s)=sum_{d=0}^{d=9}Z(l-1,s-d)$$



...with the following exit criteria:



$$Z(1,s)=0 quad text{if} quad s<0 lor s>9$$



$$Z(1,s)=1 quad text{if}quad 0 le s le 9$$



You are actually trying to calculate $Z(7, 48)-Z(6,48)$ (this eliminates all 7-digit numbers with a leading zero):



#include <iostream>
using namespace std;

int count(int length, int sum) {
if(length == 1)
return (sum >= 0 && sum <= 9)? 1: 0;
int cnt = 0;
for(int i = 0; i <= 9; i++)
cnt += count(length - 1, sum - i);
return cnt;
}

int main() {
cout << (count(7, 48) - count(6, 48));
}


...and the result is 50568.







share|cite|improve this answer












share|cite|improve this answer



share|cite|improve this answer










answered Dec 26 '18 at 10:07









OldboyOldboy

9,40711138




9,40711138












  • $begingroup$
    Thanks a lot ! I will look into the stars and bars method again to clarify it's idea.
    $endgroup$
    – Epsilon zero
    Dec 26 '18 at 10:18


















  • $begingroup$
    Thanks a lot ! I will look into the stars and bars method again to clarify it's idea.
    $endgroup$
    – Epsilon zero
    Dec 26 '18 at 10:18
















$begingroup$
Thanks a lot ! I will look into the stars and bars method again to clarify it's idea.
$endgroup$
– Epsilon zero
Dec 26 '18 at 10:18




$begingroup$
Thanks a lot ! I will look into the stars and bars method again to clarify it's idea.
$endgroup$
– Epsilon zero
Dec 26 '18 at 10:18


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3052762%2fnumber-of-7-digit-positive-integers-with-digital-sum-equal-to-48%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bundesstraße 106

Verónica Boquete

Ida-Boy-Ed-Garten