Pages: [1]   Go Down
Author Topic: Factorial problem  (Read 611 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have here a situation. The problem I was given is a number. It's about factorial.
My number is in my case 3.

So practically these are the combinations:
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1

The problem is to find out which is the probability of a specific number to be in front of another specific number? Like 3 in front of 1?
Is there any math function which describes this probability regarding the factorial number?
I'm trying to do this without making a permutation function. As I think, the permutation function would be much more complex and cpu intensive than a simple math function, therefore much more efficient.

Thank you in advance,
RobertEagle
« Last Edit: January 26, 2013, 09:03:20 am by RobertEagle » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50115
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What does this have to do with the Arduino? Go find a homework hotline to ask.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is to find out which is the probability of a specific number to be in front of another specific number? Like 3 in front of 1?
Is there any math function which describes this probability regarding the factorial number?

I don't see how that problem relates to factorials, or Arduino. In any case, the whole point of an academic assignment is that you solve the problem.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 105
Posts: 4653
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What does this have to do with the Arduino?

Well I suppose he could use the Arduino as his calculation engine after writing a sketch, and blink LEDs to signify the answer.

@OP... if that is the actual problem, you can solve it by inspection..... Count how many times n is in front of m. There are 6 combinations as you point out.... so the chance of n in front on m is easy to see.
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes. But thinking that this process actually takes a lot of cycles (the permutation and then counting), I thought there's a simpler way of getting this value. By having a mathematics function which describes this percentage.
You see, the Arduino is not that powerful for what I want. After all, there's only 16Mhz.

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50115
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You see, the Arduino is not that powerful for what I want. After all, there's only 16Mhz.
How fast the processor is has little to do with your question. Does it matter if you get the answer in 3 microseconds vs. 3 milliseconds?

Your question is about the order of values in a set of permutations. Explain what that has to do with factorial.
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 105
Posts: 4653
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the Arduino is not that powerful for what I want

Maybe it is, maybe it isn't...

But why would you do this kind of computation on a micro controller board in the first place? There are probably scores, maybe hundreds, of compilers in dozens of languages that you could download to your PC and run the program there.

Or are there things you want to control based on your answers?
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 105
Posts: 4653
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
.... permutations. Explain what that has to do with factorial

Well there's the old n! / (n-r)! stuff, maybe that's what he means.

But to me the question is, Why use an Arduino for that computation?
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your question is about the order of values in a set of permutations. Explain what that has to do with factorial.

Or programming. Or Arduino programming.

It's a homework assignment. Asking people to do it for you is cheating.

You don't need us to solve this problem for you. You don't need an Arduino, or any computer at all. You just need to sit down and think about the problem. Which was the whole point of the assignment in the first place.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Full Member
***
Karma: 0
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a local community, and this is my task. I do things, calculations, and depending on the values I turn on some things.

I have found a flaw. No matter what input data is, the percentage will always be a constant. With this, I don't even have to calculate and do something.
So going from 3 ms, to 3us, I go even further, right?

The idea when I opened a topic, was because of my curiosity. I knew how to solve the problem on the hard way, but I wanted to go further. Why all this instructions?
And PaulS, when I see that a program runs at a certain frequency and it works fine, why not optimize it?

Thank you very much for your assistance,
RobertEagle
« Last Edit: January 26, 2013, 12:04:01 pm by RobertEagle » Logged

Netherlands
Offline Offline
Full Member
***
Karma: 3
Posts: 118
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For a list of unique numbers in a random order, for a certain number to be to the left of another number, the probability is 50%: it either is or isn't to the left of the other number. No computer whatsoever is needed.

kind regards,

Jos
Logged

Pages: [1]   Go Up
Jump to: