Guest User

Untitled

a guest
May 27th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Math::Big qw/factorial/;
  4.  
  5. # Variation (Mit Beachtung der Reihenfolge) / Permutation (When order matters)
  6. # Kombination (Ohne Beachtung der Reihenfolge) / Combination (When the order does not matter)
  7.  
  8. # n = # of total
  9. # k = # of used
  10.  
  11. # Variation mit Zurücklegen / Permutation with repetition
  12. # n ** k;
  13.  
  14. # Variation ohne Zurücklegen / Permutation without repetition
  15. # n!
  16. # --------
  17. # (n - k)!
  18.  
  19. # Kombination mit Zurücklegen / Combination with repetition
  20. # (n + k - 1)!
  21. # -------------
  22. # k! * (n - 1)!
  23.  
  24. # Kombination ohne Zurücklegen / Combination without repetition
  25. # n!
  26. # -------------
  27. # k! * (n - k)!
  28.  
  29. my $n = 26;
  30. my $k = 130000;
  31.  
  32. print 'USED: ' . $k . ' OF TOTAL: ' . $n . "\n";
  33.  
  34. my $p_w_r = $n ** $k;
  35. print 'PERMUTATION WITH REPETITION: ' . $p_w_r . ' (e.g. ZAHLENSCHLOSS)' . "\n";
  36.  
  37. my $p_wo_r = factorial($n) / factorial($n - $k);
  38. print 'PERMUTATION WITHOUT REPETITION: ' . $p_wo_r . ' (e.g. REIHENFOLGE VON BILDERN AN DER WAND)' . "\n";
  39.  
  40. my $c_w_r = factorial($n + $k - 1) / (factorial($k) * factorial($n - 1));
  41. print 'COMBINATION WITH REPETITION: ' . $c_w_r . ' (e.g. GUMMIBAEREN ORACLE)' . "\n";
  42.  
  43. my $c_wo_r = factorial($n) / (factorial($k)* factorial($n-$k));
  44. print 'COMBINATION WITHOUT REPETITION: ' . $c_wo_r . ' (e.g. LOTTO, POKER)' . "\n";
Add Comment
Please, Sign In to add comment