## C#

Moderators: None (Apply to moderate this forum)
Number of posts: 5746

This Forum Only

permutation and combinations Posted by shirl on 24 Mar 2005 at 1:23 PM

I'm working permutation and combinations on the GUI and the user inputs the n and the m.
The permutation of n things taken m at a time is
n!/(n-m)!
The combination of n things taken m at a time is
n!/(n-m)!m!

Re: permutation and combinations Posted by IDK on 25 Mar 2005 at 11:13 AM
:
: I'm working permutation and combinations on the GUI and the user inputs the n and the m.
: The permutation of n things taken m at a time is
: n!/(n-m)!
: The combination of n things taken m at a time is
: n!/(n-m)!m!
:
:
The Permutation function is really funny to do so I leave that to you.
Hint: use a recursive method (n!=n(n-1)!),(1!=1)

Then its really easy to do the rest.
The first function would look like: permutation(n)/permutation(n-m)
And the second like; permutation(n)/permutation(n-m)*permutation(m)

Really easy

(who doesn't know how to spell in inglish)

Re: permutation and combinations Posted by shirl on 26 Mar 2005 at 2:21 PM
: :
: : I'm working permutation and combinations on the GUI and the user inputs the n and the m.
: : The permutation of n things taken m at a time is
: : n!/(n-m)!
: : The combination of n things taken m at a time is
: : n!/(n-m)!m!
: :
: :
: The Permutation function is really funny to do so I leave that to you.
: Hint: use a recursive method (n!=n(n-1)!),(1!=1)
:
: Then its really easy to do the rest.
: The first function would look like: permutation(n)/permutation(n-m)
: And the second like; permutation(n)/permutation(n-m)*permutation(m)
:
: Really easy
:

: (who doesn't know how to spell in inglish)
:
: Can you tell me nore about it IDK becayse I'm stiil having some difficulties
: thanks
shirl
:
Re: permutation and combinations Posted by IDK on 29 Mar 2005 at 11:30 AM
This message was edited by IDK at 2005-3-29 11:30:35

The permutation function sould look like:
```public int perm(int n)
{
if(n==1)
return 1;
else
return n*perm(n-1);
}
```

I have NOT compiled this but it should work
This is what they give as an example of a
recursive method.

(who doesn't know how to spell in inglish)

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic