Ask your own question, for FREE!
Mathematics 17 Online
OpenStudy (anonymous):

A good one too, I guess. Determine the number of positive integers x, where x is less than equal to 9,999,999 and the sum of the digits in x is 31.

OpenStudy (anonymous):

4,869,117

OpenStudy (anonymous):

there are many posibilities

OpenStudy (anonymous):

Exactly. You have to find the exact number of such possibilities. :)

OpenStudy (anonymous):

how ? too hard

OpenStudy (anonymous):

Easy wouldnt have half the fun, would it? :P

OpenStudy (anonymous):

two and three-digit numbers wouldn't add up to 31. so start with 4 digit numbers

OpenStudy (henryblah):

And 9994000 is the highest it can go. So start counting! :) Though I guess the problem can be solved much more simply.

OpenStudy (inkyvoyd):

This is what python is for.

OpenStudy (inkyvoyd):

(or mathematica)

OpenStudy (anonymous):

Haha. Got to have an easier wayy guyss.

OpenStudy (inkyvoyd):

a+b+c+d+e+f+g<=31

OpenStudy (anonymous):

No. =31.

OpenStudy (inkyvoyd):

a<9 b<9 c<9 d<9 e<9 f<9

OpenStudy (inkyvoyd):

Oh. ok.

OpenStudy (anonymous):

And then youd have to make cases. 4 digit. 5digit. 6digit.....

OpenStudy (anonymous):

just linear programming to solve the problem

OpenStudy (inkyvoyd):

1000000a+100000b+10000c+1000d+100e+10f+g=9,999,999

OpenStudy (inkyvoyd):

a+b+c+d+e+f+g=31

OpenStudy (anonymous):

And the Coeff. wouldnt be easy to calculate either because of restricted range. @LoneDrifter - In a maths test- Tough luck.

OpenStudy (inkyvoyd):

a, b, c, d, e, f, and g, could equal zero(though not more than 3, obviously)

OpenStudy (anonymous):

Simplex algorithm might be able to solve it but very long winded

OpenStudy (inkyvoyd):

Then, I'm not sure how to include the positive integers.

OpenStudy (anonymous):

Inkyvoyd,,For the first condition <= 9999999

OpenStudy (anonymous):

(number of possible sums that add up to 31)*(all possible permutations of the numbers)

OpenStudy (inkyvoyd):

Then, the problem reduces down to looking for sums that equal 31

OpenStudy (anonymous):

@LoneDrifter No. s repitition in numbers will stop such a direct formula. Youd have to do each case individually.

OpenStudy (inkyvoyd):

@siddhantsharan , am I even on track?

OpenStudy (anonymous):

you can take out the repetition of digits when working out permutation of the numbers

OpenStudy (anonymous):

I dunno myself. I dont have the solution. And I havent figured out one. Just figured out what we CANT do. :P

OpenStudy (anonymous):

It may be easier to solve problem on paper if you solve by programming first.

OpenStudy (inkyvoyd):

1000000a+100000b+10000c+1000d+100e+10f+g<=9,999,999 a+b+c+d+e+f+g=31 999999a+99999b+9999c+999d+99e+9f<=9999968 divide both sides by 9 111111a+11111b+1111c+111d+11e+f<=1111107

OpenStudy (anonymous):

@LoneDrifter How? For egs. while figuring out no. of numbers who give the sum of 31, you may get a no. like Say, aabcd And one with all unique digits, abcd --- How would you differentiate in permutations. Maybe its easier. Not a programmer myself so :(. But if you could workout the answer - Would def. help.

OpenStudy (inkyvoyd):

Maybe play with the permutations that way.

OpenStudy (inkyvoyd):

when a=9, subtract both sides

OpenStudy (anonymous):

Nice. Makes sense. Now to go further from here.

OpenStudy (inkyvoyd):

11111b+1111c+111d+11e+f<=111,108

OpenStudy (inkyvoyd):

This won't work.

OpenStudy (inkyvoyd):

We need to reduce the problem further before brute force.

OpenStudy (inkyvoyd):

We need to solve the probability probem that @LoneDrifter proposed.

OpenStudy (anonymous):

knowing possible combination of numbers that add up to 31 if first task then split these combinations into separate list for the number of repeated digits they contain once we have this it is simple permutation problem

OpenStudy (anonymous):

I do not mean real list obviously but so we know there are 15 with all unique digits, 23 with one repeated digit and so on

OpenStudy (inkyvoyd):

http://en.wikipedia.org/wiki/Subset_sum_problem If i'm correct, this means that we have an NP hard problem.

OpenStudy (inkyvoyd):

I'm just going to try to write a computer program to brute force this.

OpenStudy (anonymous):

that was my plan but i want to see if we can find an elegant solution first

OpenStudy (anonymous):

Hmmmm. Dinner time here. Will get back to this in a while. :) I think an elegant solution must exist for this. Its an exam question, after all.

OpenStudy (inkyvoyd):

Well, I just found that it's most likely NP-hard unless you can find some special case

OpenStudy (inkyvoyd):

wait, tell me what subject this is.

OpenStudy (anonymous):

Maths. Entrance exam question. :)

OpenStudy (anonymous):

how long are you given?

OpenStudy (inkyvoyd):

No, is there a specific sub-subject?

OpenStudy (inkyvoyd):

Like, discrete, linear, calculus, etc

OpenStudy (anonymous):

looks like a discrete problem

OpenStudy (anonymous):

NP-hard. The good news just keeps coming. :P Permutations and Combinations I guess. It can be discrete though.

OpenStudy (anonymous):

1 hour for about 40-50 questions

OpenStudy (anonymous):

so your suppose to solve it in around 2 minutes

OpenStudy (anonymous):

Apparently.

OpenStudy (anonymous):

seems we are missing something very obvious then

OpenStudy (anonymous):

are the other questions this tricky?

OpenStudy (inkyvoyd):

Well, let's read up on wikipedia, for the knapsack problem.

OpenStudy (inkyvoyd):

http://en.wikipedia.org/wiki/Knapsack_problem

OpenStudy (inkyvoyd):

I'm going to stop here, because I"m completely useless. I haven't even taken trig, though I have read up to calc2

OpenStudy (anonymous):

I could do this problem... but it's a nightmare.

OpenStudy (anonymous):

Thanks that's so helpful

OpenStudy (anonymous):

35

OpenStudy (inkyvoyd):

@siddhantsharan , want me to write a computer program to test? (*try to write a program*)

OpenStudy (kinggeorge):

The only way I see to do this is to find how many ways can we partition 31 without exceeding 7 partitions, and each element of the partition is less than or equal to 9. This is a rather difficult problem.

OpenStudy (anonymous):

answer is 35

OpenStudy (inkyvoyd):

sahil, that is sort of hard to take without any form of work shown.

OpenStudy (anonymous):

@inkyvoyd That would be great.

OpenStudy (kinggeorge):

Excuse what I said above, we need to find how many ordered partitions of 31 that have exactly 7 partitions, and each element of the partition is less than or equal to 9. So if we get one partition, switching two numbers within the partition would give us a different solution. I'm not sure if this is harder or easier.

OpenStudy (inkyvoyd):

This will take some time, because I forgot how to do most of the stuff. I should be able to do it though.

OpenStudy (anonymous):

I got digit sum 31 in a case when there are 3 9's and 4 1's now ways to get this is 35 as Fact(7)/(fact(3)*fact(4)) ie 35 no other possibility is there

OpenStudy (kinggeorge):

What if there were 3 9's and one 4?

OpenStudy (inkyvoyd):

How bout 2 9's and 3 ones and one 2?

OpenStudy (asnaseer):

KingGeorge: I believe ordered partitions are known as compositions, which is what you need to find here. see here: http://en.wikipedia.org/wiki/Composition_%28number_theory%29

OpenStudy (kinggeorge):

That is exactly what I was looking for, and it may be easier than ordinary partitions using some recursive steps.

OpenStudy (asnaseer):

I think it has a well known formula - look further down on that link I pasted above.

OpenStudy (asnaseer):

I think, in this case, the answer would be:\[2^{31-1}\]

OpenStudy (asnaseer):

but that doesn't /feel/ right as we have not considered the restriction of 7 digits.

OpenStudy (kinggeorge):

But that number is including partitions such as \((30, 1)\) and we want to exclude it. You would have to start with \((9, 9, 9, 4)\) and start breaking each digit up individually, and finding each combination of digits that doesn't repeat.

OpenStudy (anonymous):

oh yes we can also get 3 9's 1 )4) and 3 0's 3 9's one 3 and one 1 and 2 zero 3 9's 2 two's and two zero also answer is 805

OpenStudy (asnaseer):

ah yes - I think you have it KingGeorge!

OpenStudy (inkyvoyd):

He has it, and I'm far from done with this program -.-

OpenStudy (kinggeorge):

But there are other restrictions we must consider too, and right now, we would still end up with about 30 different cases. For example, each number must not be divided up into anymore than 4 partitions, but if we partition 9 into 8+1, then we can add the 1 to the four and get (9,9,8,5), which means we can still partition any number into 4 different numbers. There's just so many separate cases to consider, that I don't know where to start. So I will leave for the time and get food.

OpenStudy (anonymous):

@KingGeorge I tried that. But, first I checked how many mere unordered possibilities are possible. And that itself is 259185. So that method is pretty impractical.

OpenStudy (inkyvoyd):

It's running. Hopefully I wrote it correctly. View source code at: http://pastebin.com/KhRm2vNL

OpenStudy (inkyvoyd):

I should try writting it in C++, but I doubt I have the skills.

OpenStudy (inkyvoyd):

Written in both C++ and python now, because python wouldn't work.

OpenStudy (inkyvoyd):

http://pastebin.com/Wq4kaSB3

OpenStudy (inkyvoyd):

Please check my source code for errors. THank you.

OpenStudy (inkyvoyd):

Ok, my source code definitely has issues.

OpenStudy (anonymous):

Haha. Frustrating this is.

OpenStudy (anonymous):

@amistre64 , Help?

OpenStudy (inkyvoyd):

512365

OpenStudy (inkyvoyd):

My new source code. http://pastebin.com/qSJCXiYC

OpenStudy (inkyvoyd):

and you can divide by 7, so it's looking good. I'm going to write another program to try to find it the smarter way, with just adding the numbers...

OpenStudy (inkyvoyd):

lol, it literally takes 3 seconds for it to finish running.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!