|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jaige.util.MathTools
public class MathTools
Method Summary | ||
---|---|---|
static int |
combinations(int n,
int r)
Given the total number of choices 'n', and the total number chosen 'r', returns the total number of combinations that can be chosen. |
|
static java.lang.Object[][] |
combinations(java.lang.Object[] choices,
int choose)
Returns 'choose' combinations of 'choices' in an Object[][]. |
|
static void |
combinations(java.lang.Object[] choices,
java.lang.Object[][] results)
Returns all combinations of the 'choices'. |
|
static int |
factorial(int n)
Returns the mathmatical factorial of 'n'. |
|
static long |
factorial(long n)
Returns the mathmatical factorial of 'n'. |
|
static void |
main(java.lang.String[] args)
|
|
static
|
permutations(java.util.ArrayList<T> choices,
int choose,
java.util.ArrayList<java.util.ArrayList<T>> results)
|
|
static int |
permutations(int n,
int r)
Given the total number of choices 'n', and the total number chosen 'r', returns the total number of permutations that can be chosen. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.Object[][] combinations(java.lang.Object[] choices, int choose)
choices
- Object[] Things to choose fromchoose
- int Number to choose
public static void combinations(java.lang.Object[] choices, java.lang.Object[][] results)
choices
- Object[] Things to choose fromresults
- Object[][] All combinations requested from 'choices'.public static <T> void permutations(java.util.ArrayList<T> choices, int choose, java.util.ArrayList<java.util.ArrayList<T>> results)
public static int combinations(int n, int r)
n
- int Number of choicesr
- int Number to choose
public static int permutations(int n, int r)
return factorial(n) / factorial(n-r);
where there are 2n-r multiplications,
this method is recursive and performs n-r multiplications.
n
- int Number of choicesr
- int Number to choose
public static long factorial(long n)
n
- long value to perform factorial on, but be <= 20 and >= 0
public static int factorial(int n)
n
- long value to perform factorial on, but be <= 12 and >= 0
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |