prog.sf 658 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/ruby
  2. # Indices k such that A002533(k) is prime.
  3. # https://oeis.org/A372491
  4. # Known terms:
  5. # 2, 3, 4, 5, 11, 17, 32, 53, 103, 107, 109, 113, 137, 197, 233, 811, 7993, 9281, 14387, 26573, 51361
  6. # It's very hard to find the next term, as most terms do not have small factors,
  7. # therefore we need to run a pseudoprime test on most numbers, which each take several seconds.
  8. Num!VERBOSE = true
  9. var from = 51481
  10. for k in (from..1e9) {
  11. k.is_prime || k.is_power_of(2) || next
  12. var v = Math.linear_rec([2,5], [1,1], k)
  13. say ":: Testing: #{k} (length: #{v.len})"
  14. if (v.is_prob_prime) {
  15. die "\nFound new term: #{k}\n"
  16. }
  17. }