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

#### lincoln40113

##### New Member
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

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
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

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.
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

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
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.