063 Powerful digit counts.pl 390 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/perl
  2. # Daniel "Trizen" Șuteu
  3. # License: GPLv3
  4. # Date: 28 January 2017
  5. # https://github.com/trizen
  6. # https://projecteuler.net/problem=63
  7. # Runtime: 0.026s
  8. use 5.010;
  9. use strict;
  10. use Math::GMP qw(:constant);
  11. my $count = 0;
  12. for (my $n = 1 ; $n < 10 ; ++$n) {
  13. foreach my $m (1 .. 3*$n) { # just works™
  14. ++$count if (length($n**$m) == $m);
  15. }
  16. }
  17. say $count;