C#

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

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

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

Can you please help me on how to convert this in c# code
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!

Report
Re: permutation and combinations Posted by IDK on 25 Mar 2005 at 11:13 AM
:
: Can you please help me on how to convert this in c# code
: 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


El PROgrammador Niklas Ulvinge
(who doesn't know how to spell in inglish)

Report
Re: permutation and combinations Posted by shirl on 26 Mar 2005 at 2:21 PM
: :
: : Can you please help me on how to convert this in c# code
: : 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
:

: El PROgrammador Niklas Ulvinge
: (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
:
Report
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.


El PROgrammador Niklas Ulvinge
(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
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.