The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
#!/usr/bin/perl

use Term::ProgressBar 2.00;

use constant MAX => 1_000_000;

my $max = int($ARGV[0]+0) || MAX;
my $progress = Term::ProgressBar->new({name => 'Powers', count => $max,
                                       ETA => linear, });
#$progress->minor(0);
my $next_update = 0;

for (0..$max) {
  my $is_power = 0;
  for(my $i = 0; 2**$i <= $_; $i++) {
    $is_power = 1
      if 2**$i == $_;
  }
sleep 1
if $_ % 4 == 0;

  $next_update = $progress->update($_)
    if $_ > $next_update;
}
$progress->update($max)
    if $max >= $next_update;