prog.sf 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/ruby
  2. # a(n) is the smallest number k such that factorizations of n consecutive integers starting at k have the same excess of number of primes counted with multiplicity over number of primes counted without multiplicity (A046660).
  3. # https://oeis.org/A323253
  4. # See also:
  5. # https://oeis.org/A072072
  6. # https://oeis.org/A071125
  7. var range = @(1..100)
  8. func excess (n) {
  9. n.bigomega - n.omega
  10. }
  11. func score(n) {
  12. var t = excess(n)
  13. range.first_by {|k| excess(n+k) != t }
  14. }
  15. say score(80566783622) #=> 6
  16. say score(30199064929748) #=> 1
  17. say score(341249411050244) #=> 8
  18. say [844, 74849, 671346, 8870025, 254023231417746].map(score) #=> [4, 5, 6, 7, 8]
  19. __END__
  20. var n = 1
  21. for k in (1..1e5) {
  22. while (isok(k) >= n) {
  23. say "a(#{n}) = #{k}"
  24. ++n
  25. }
  26. }
  27. __END__
  28. \\ PARI code
  29. excess(n) = bigomega(n) - omega(n);
  30. score(n) = my(t=excess(n)); for(k=1, oo, if(excess(n+k) != t, return(k)));
  31. upto(nn) = my(n=1); for(k=1, nn, while(score(k) >= n, print1(k, ", "); n++)); \\ ~~~~
  32. __END__
  33. Factors of k+j for j = 0..7, where k = 341249411050244:
  34. [2, 2, 23, 23, 37, 10601, 411157]
  35. [3, 3, 3, 5, 717919, 3520973]
  36. [2, 19, 19, 19, 43, 15919, 36341]
  37. [7, 7, 7, 994896242129]
  38. [2, 2, 2, 3, 61, 211, 1104710237]
  39. [13, 13, 13, 155325175717]
  40. [2, 5, 5, 5, 31, 2591, 16994281]
  41. [3, 11, 11, 11, 1609, 53114923]
  42. Factors of k+j for j = 0..7, where k = 254023231417746:
  43. [2, 3, 7, 7, 7, 174431, 707627]
  44. [11, 11, 11, 863, 3329, 66431]
  45. [2, 2, 13, 13, 223, 1685085251]
  46. [3, 3, 3, 95857, 98148991]
  47. [2, 5, 5, 5, 9001, 112886671]
  48. [19, 19, 47, 47, 97, 3283967]
  49. [2, 2, 2, 3, 10584301309073]
  50. [7, 23, 23, 23, 599, 4979263]