I'm working on a separate program which has a bunch of gui
, so I made a simpler program in an attempt to ask for help.
I don't really know permutations
and combinations
that well.
Anyway, I have a piece of code here which solves this function:
F (n,r) = n!/(r!(n-r)!)
You can change the n and r in the code and it'll give you the answer for those two inputs.
public class peanuts
{
static int n,r;
public static void main (String[] args)
{
n= 8;
r=3;
int m=1;
if(n>>1 < r)
r = n - r;
for(int o=n+1-r;o<n+1;o++)
m *= o;
for(int o=r;o>0;o--)
m /= o;
Math.round(m);
System.out.println ("C("+n+","+r+ ") is "+ m );
}}
I want to modify it slightly so it solves this permutation function:
F (n,r) = n!/(n-r)!)