fork(1) download
  1. #!/usr/bin/perl
  2. use 5.016;
  3. use warnings;
  4.  
  5. sub gcd { $_[1] ? gcd($_[1], $_[0] % $_[1]) : $_[0] }
  6. sub lcm { $_[0] * $_[1] / gcd($_[0], $_[1]) }
  7.  
  8. sub f {
  9. my ($p, $q, $e) = @_;
  10.  
  11. my $lcm = lcm($p - 1, $q - 1);
  12.  
  13. return map{ $_ / $e }
  14. grep{ !($_ % $e) }
  15. map{ $_ * $lcm + 1 } (1 .. $p * $q / $lcm);
  16. }
  17.  
  18. say join ' ', f(map{ <STDIN> }(1 .. 3));
  19.  
Success #stdin #stdout 0s 3736KB
stdin
5
7
5
stdout
5