prog.pl 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/perl
  2. # a(n) is the smallest centered square number with exactly n prime factors (counted with multiplicity).
  3. # https://oeis.org/A359235
  4. # Previously known terms:
  5. # 1, 5, 25, 925, 1625, 47125, 2115625, 4330625, 83760625, 1049140625, 6098828125, 224991015625, 3735483578125, 329495166015625
  6. # New terms found:
  7. # a(14) = 8193863401953125
  8. # a(15) = 7604781494140625
  9. # a(16) = 216431299462890625
  10. # a(17) = 148146624615478515625
  11. # a(18) = 25926420587158203125
  12. # a(19) = 11071085186929931640625
  13. # Terms:
  14. # 1, 5, 25, 925, 1625, 47125, 2115625, 4330625, 83760625, 1049140625, 6098828125, 224991015625, 3735483578125, 329495166015625, 8193863401953125, 7604781494140625, 216431299462890625, 148146624615478515625, 25926420587158203125, 11071085186929931640625
  15. use 5.020;
  16. use warnings;
  17. use ntheory qw(:all);
  18. use experimental qw(signatures);
  19. # PARI/GP program:
  20. # a(n) = for(k=0, oo, my(t=2*k*k + 2*k + 1); if(bigomega(t) == n, return(t))); \\ ~~~~
  21. =for PARI/GP
  22. bigomega_centered_square_numbers(A, B, n) = A=max(A, 2^n); (f(m, p, n) = my(list=List()); if(n==1, forprime(q=max(p,ceil(A/m)), B\m, if(q%4==1, my(t=m*q); if(issquare((8*(t-1))/4 + 1) && ((sqrtint((8*(t-1))/4 + 1)-1)%2 == 0), listput(list, t)))), forprime(q=p, sqrtnint(B\m, n), if(q%4==1, my(t=m*q); if(ceil(A/t) <= B\t, list=concat(list, f(t, q, n-1)))))); list); vecsort(Vec(f(1, 2, n)));
  23. a(n) = if(n==0, return(1)); my(x=2^n, y=2*x); while(1, my(v=bigomega_centered_square_numbers(x, y, n)); if(#v >= 1, return(v[1])); x=y+1; y=2*x); \\ ~~~~
  24. =cut
  25. sub a($n) {
  26. for(my $k = 0; ;++$k) {
  27. my $v = divint(mulint(4*$k, ($k + 1)), 2) + 1;
  28. if (is_almost_prime($n, $v)) {
  29. return $v;
  30. }
  31. }
  32. }
  33. foreach my $n(1..100) {
  34. say "a($n) = ", a($n);
  35. }
  36. __END__
  37. a(1) = 5
  38. a(2) = 25
  39. a(3) = 925
  40. a(4) = 1625
  41. a(5) = 47125
  42. a(6) = 2115625
  43. a(7) = 4330625
  44. a(8) = 83760625
  45. a(9) = 1049140625
  46. a(10) = 6098828125
  47. a(11) = 224991015625
  48. a(12) = 3735483578125
  49. a(13) = 329495166015625
  50. a(14) = 8193863401953125