prog.pl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/perl
  2. # Numbers k such that phi(k) = (sum of digits of k)!.
  3. # https://oeis.org/A???????
  4. use 5.020;
  5. use strict;
  6. use warnings;
  7. use ntheory qw(:all);
  8. use experimental qw(signatures);
  9. #use Math::AnyNum qw();
  10. #use Math::GMPz;
  11. #use Math::GMP qw(:constant);
  12. # Finding terms for t = 16, requires over 6 GB of RAM.
  13. my @values;
  14. foreach my $t (1..15) {
  15. say "Processing: $t";
  16. my $n = factorial($t);
  17. foreach my $k (inverse_totient($n)) {
  18. #say "Testing: $k";
  19. if (vecsum(split(//, $k)) == $t) {
  20. push @values, $k;
  21. }
  22. }
  23. }
  24. local $| = 1;
  25. foreach my $value (sort { $a <=> $b } @values) {
  26. print($value, ", ");
  27. }
  28. say '';
  29. __END__
  30. 1, 1221, 101600, 112112, 121220, 1310022, 1412010, 1600200, 10071100, 10100350, 10311400, 10612000, 10621000, 11002600, 12130300, 100020080, 102202400, 104111300, 110100530, 113321000, 120020600, 1011041031, 1112011005, 2010003600, 2010232200, 2011012410, 2011110024, 2013030012, 2023030020, 2023210200, 2031011400, 2100710010, 2101140300, 2102050020, 2110110240, 2133012000, 16000132000, 100105041101, 102202041011, 102511020101, 103000314011, 111021340001, 232110023000, 233110101020, 240120002300, 2102001113013, 2200014130011, 3102220000005