HELP! probability that a 7 digit number is divisible by 7?

#1
The seven digits {1; 2; 3; 4; 5; 6; 7} are written down in a random order. What is the
chance that the resulting number is divisible by 7? For instance, 1234576 works, but
1234567 doesn’t.
 

Dason

Ambassador to the humans
#2
Hi! :welcome: We are glad that you posted here! This looks like a homework question though. Our homework help policy can be found here. We mainly just want to see what you have tried so far and that you have put some effort into the problem. I would also suggest checking out this thread for some guidelines on smart posting behavior that can help you get answers that are better much more quickly.
 

hlsmith

Omega Contributor
#3
What Dason said. Or you could see how may of the 5040 combinations (i.e., 7!) of the numbers are divisible by 7. Then take that number divided by 5040 to get the probability.
 

Dason

Ambassador to the humans
#4
I brute forced the solution and the answer is quite nice. The problem is I can't find a nice alternative reason for why that answer is what it is...
 

spunky

Smelly poop man with doo doo pants.
#6
I brute forced the solution and the answer is quite nice. The problem is I can't find a nice alternative reason for why that answer is what it is...
how did you do it? i was thinking on taking that approach as well.

i know it's inefficient but i was basically planning on have a list of numbers from 1111111 to 7777777 and then just let R see whether there were any repeated digits in any given numbers and, if they were, throw them out so i ended up with the sub-set that's needed.
 

Dason

Ambassador to the humans
#7
how did you do it? i was thinking on taking that approach as well.

i know it's inefficient but i was basically planning on have a list of numbers from 1111111 to 7777777 and then just let R see whether there were any repeated digits in any given numbers and, if they were, throw them out so i ended up with the sub-set that's needed.
The permn function in the combinat package will create all the permutations for you. Alternatively - check the chatbox.
 

hlsmith

Omega Contributor
#8
Spunky I like you straight forward idea. Dason would Spunky's code run faster than yours or within 3-4Xs the other package?

Side note, I think the OP was looking for a formula style equation just to plug numbers into, does one of those exist, if so would that run faster than your code Dason, probably. Not ripping on your code but woundering about the most efficient method. Seems like a BGM question. Somebody put out the factorial bat signal.

Looks like the cyclone > golden hurricane + residuals.
 

Dason

Ambassador to the humans
#9
The issue is that I don't know of a nice test for divisibility by 7. It's not like 2 or 5 where you can just look at the digit in the 1s place or like 3 where you can look at if the sum of all the digits is divisible by 3...

And I doubt Spunky's code would run faster than mine. spunky would need to check 7777777-1111111 = 6666666 values whereas mine just needs to check 7!=5040 values.

Edit: Although you could make spunky's approach slightly better by only starting at 1234567 and ending at 7654321.
 
Last edited: