prog.sf 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/ruby
  2. # a(n) is the index of the smallest square pyramidal number with exactly n prime factors (counted with multiplicity).
  3. # https://oeis.org/A359193
  4. # Previously known terms:
  5. # 1, 2, 3, 4, 7, 15, 24, 31, 63, 80, 175, 255, 511, 1023, 512, 6912, 2047, 6655, 14336, 16384, 32767, 90112, 131071, 180224, 483327, 1114112
  6. # New terms a(26)-a(34):
  7. # 1638400, 2097151, 1048575, 16777216, 8388607, 33357824, 16777215, 92274687, 67108864
  8. #`(
  9. # PARI/GP program:
  10. a(n) = for(k=1, oo, my(t=(k*(k+1)*(2*k + 1))\6); if(bigomega(t) == n, return(k))); \\ ~~~~
  11. )
  12. func a(n) {
  13. for k in (1..Inf) {
  14. if (pyramidal(k, 4).is_almost_prime(n)) {
  15. return k
  16. }
  17. }
  18. }
  19. for n in (1..100) {
  20. say "a(#{n}) = #{a(n)}"
  21. }
  22. __END__
  23. a(1) = 2
  24. a(2) = 3
  25. a(3) = 4
  26. a(4) = 7
  27. a(5) = 15
  28. a(6) = 24
  29. a(7) = 31
  30. a(8) = 63
  31. a(9) = 80
  32. a(10) = 175
  33. a(11) = 255
  34. a(12) = 511
  35. a(13) = 1023
  36. a(14) = 512
  37. a(15) = 6912
  38. a(16) = 2047
  39. a(17) = 6655
  40. a(18) = 14336
  41. a(19) = 16384
  42. a(20) = 32767
  43. a(21) = 90112
  44. a(22) = 131071
  45. a(23) = 180224
  46. a(24) = 483327
  47. a(25) = 1114112
  48. a(26) = 1638400
  49. a(27) = 2097151
  50. a(28) = 1048575
  51. a(29) = 16777216
  52. a(30) = 8388607
  53. a(31) = 33357824
  54. a(32) = 16777215
  55. a(33) = 92274687
  56. a(34) = 67108864