search_2.sf 542 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/ruby
  2. # Numbers k such that A003415(sigma(k)) = k, where A003415 is the arithmetic derivative, and sigma is the sum of divisors of n.
  3. # https://oeis.org/A342021
  4. # Known terms:
  5. # 5, 8, 41, 47057
  6. var min = 1
  7. var max = 1e8
  8. for n in (2..100) {
  9. var count = n.squarefree_almost_prime_count(min, max) || break
  10. say "\nTesting: n = #{n} (count: #{count})\n"
  11. n.each_squarefree_almost_prime(min, max, {|p|
  12. p.dec.is_prime || next
  13. if (p.derivative == p-1) {
  14. print(p-1, ", ")
  15. }
  16. })
  17. }