Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.hswt.bp4524.klee;
- public class MainClass {
- /**
- * @param args
- */
- public static void main(String[] args) {
- System.out.println(comb(49,50));
- }
- public static long comb(int n, int k){
- long ergebnis;
- if (k > n) throw new IllegalArgumentException( "k muss kleiner n sein!" );
- if (k == 0) return 1;
- if (2*k > n){ ergebnis = comb(n,n-k);
- return ergebnis;
- }
- else {
- ergebnis = n-k+1;
- for (int i = 2; i <= k; i++){
- ergebnis = ergebnis*(n-k+i);
- ergebnis = ergebnis/i;
- }
- return ergebnis;
- }
- // return ergebnis;
- }
- }
Add Comment
Please, Sign In to add comment