prog.sf 1013 B

123456789101112131415161718192021222324
  1. #!/usr/bin/ruby
  2. # Least non-palindromic number k such that k and its digital reversal both have exactly n prime divisors.
  3. # https://oeis.org/A113548
  4. # Known terms:
  5. # 13, 12, 132, 1518, 15015, 204204, 10444434, 241879638, 20340535215, 242194868916
  6. # a(n) >= A239696(n).
  7. # This sequence does not allow ending in 0, else a(8) = 208888680, a(11) = 64635504163230 and a(13) = 477566276048801940. - Michael S. Branicky, Feb 14 2023
  8. # New terms (a(11)-a(12)):
  9. # 136969856585562, 2400532020354468
  10. #`(
  11. # PARI/GP program:
  12. generate(A, B, n) = A=max(A, vecprod(primes(n))); (f(m, p, j) = my(list=List()); forprime(q=p, sqrtnint(B\m, j), if(q==5 && m%2==0, next); my(v=m*q); while(v <= B, if(j==1, my(r=fromdigits(Vecrev(digits(v)))); if(v>=A && r != v && omega(r) == n, listput(list, v)), if(v*(q+1) <= B, list=concat(list, f(v, q+1, j-1)))); v *= q)); list); vecsort(Vec(f(1, 2, n)));
  13. a(n) = my(x=vecprod(primes(n)), y=2*x); while(1, my(v=generate(x, y, n)); if(#v >= 1, return(v[1])); x=y+1; y=2*x); \\ ~~~~
  14. )