Go Down

### Topic: Factorial problem (Read 2248 times)previous topic - next topic

#### RobertEagle

##### Jan 26, 2013, 03:00 pmLast Edit: Jan 26, 2013, 03:03 pm by RobertEagle Reason: 1
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.

RobertEagle

#### PaulS

#1
##### Jan 26, 2013, 03:30 pm
What does this have to do with the Arduino? Go find a homework hotline to ask.

#### PeterH

#2
##### Jan 26, 2013, 04:01 pm

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.

#### JimboZA

#3
##### Jan 26, 2013, 04:15 pm

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.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)

#### RobertEagle

#4
##### Jan 26, 2013, 04:53 pm
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.

#### PaulS

#5
##### Jan 26, 2013, 05:01 pm
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.

#### JimboZA

#6
##### Jan 26, 2013, 05:01 pm
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?
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)

#### JimboZA

#7
##### Jan 26, 2013, 05:06 pm
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?
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)

#### PeterH

#8
##### Jan 26, 2013, 05:49 pm

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.

#### RobertEagle

#9
##### Jan 26, 2013, 06:01 pmLast Edit: Jan 26, 2013, 06:04 pm by RobertEagle Reason: 1
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

#### JosAH

#10
##### Jan 26, 2013, 06:38 pm
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

Go Up