Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use strict;
- use Math::Big qw/factorial/;
- # Variation (Mit Beachtung der Reihenfolge) / Permutation (When order matters)
- # Kombination (Ohne Beachtung der Reihenfolge) / Combination (When the order does not matter)
- # n = # of total
- # k = # of used
- # Variation mit Zurücklegen / Permutation with repetition
- # n ** k;
- # Variation ohne Zurücklegen / Permutation without repetition
- # n!
- # --------
- # (n - k)!
- # Kombination mit Zurücklegen / Combination with repetition
- # (n + k - 1)!
- # -------------
- # k! * (n - 1)!
- # Kombination ohne Zurücklegen / Combination without repetition
- # n!
- # -------------
- # k! * (n - k)!
- my $n = 26;
- my $k = 130000;
- print 'USED: ' . $k . ' OF TOTAL: ' . $n . "\n";
- my $p_w_r = $n ** $k;
- print 'PERMUTATION WITH REPETITION: ' . $p_w_r . ' (e.g. ZAHLENSCHLOSS)' . "\n";
- my $p_wo_r = factorial($n) / factorial($n - $k);
- print 'PERMUTATION WITHOUT REPETITION: ' . $p_wo_r . ' (e.g. REIHENFOLGE VON BILDERN AN DER WAND)' . "\n";
- my $c_w_r = factorial($n + $k - 1) / (factorial($k) * factorial($n - 1));
- print 'COMBINATION WITH REPETITION: ' . $c_w_r . ' (e.g. GUMMIBAEREN ORACLE)' . "\n";
- my $c_wo_r = factorial($n) / (factorial($k)* factorial($n-$k));
- print 'COMBINATION WITHOUT REPETITION: ' . $c_wo_r . ' (e.g. LOTTO, POKER)' . "\n";
Add Comment
Please, Sign In to add comment