Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
        my $avg =$total / (2 ** $i - 1);
        print "For range 1 .. $last, total guesses = $total, avg = $avg\n"
    +;
    }
    
  2. or download this
    For range 1 .. 1, total guesses = 1, avg = 1
    For range 1 .. 3, total guesses = 5, avg = 1.66666666666667
    ...
    For range 1 .. 262143, total guesses = 4456449, avg = 17.0000686648127
    For range 1 .. 524287, total guesses = 9437185, avg = 18.0000362396931
    For range 1 .. 1048575, total guesses = 19922945, avg = 19.00001907350
    +45