Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- $| =1;
- my @bitC = (0.075, 0.15, 0.3, 0.6, 1.18, 2.35, 4.7, 9.4, 18.8, 37.6);
- # the value combinations according to bit.
- #2 power n = prosibility as n bit.
- for (my $i = 0; $i<2**scalar(@bitC); $i++){
- my @bits = split(//,sprintf ("%b", $i));
- print $i." as bin:";
- my $capa = 0;
- my $c =scalar(@bits);
- foreach (@bits){
- print $_;
- if ( $_ == 1 ) {
- $capa = $capa + $bitC[$c - 1]; $c--;
- }else {$capa = $capa +0 ; $c--;}
- }
- print " : ".$capa."\n";
- #print $capa."\n";
- print "\n";
- }
- sleep();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement