File: powers2

package info (click to toggle)
libterm-progressbar-perl 2.23-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 224 kB
  • sloc: perl: 596; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 326 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl
use strict;
use warnings;

use Term::ProgressBar 2.00;

use constant MAX => 100_000;

my $max = int($ARGV[0] || MAX);
my $progress = Term::ProgressBar->new($max);

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

  $progress->update($_);
}