133 Repunit nonfactors -- v2.pl 483 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/perl
  2. # Daniel "Trizen" Șuteu
  3. # Date: 21 September 2019
  4. # https://github.com/trizen
  5. # https://projecteuler.net/problem=133
  6. # Runtime: 0.042s
  7. # See also:
  8. # https://oeis.org/A178070
  9. use 5.010;
  10. use strict;
  11. use warnings;
  12. use ntheory qw(:all);
  13. my $limit = 100_000;
  14. my %factors;
  15. my $N = powint(10, logint($limit, 2));
  16. forprimes {
  17. if ($N % znorder(10, $_) == 0) {
  18. $factors{$_} = 1;
  19. }
  20. } 7, $limit;
  21. say vecsum(grep { !$factors{$_} } @{primes($limit)});