prog.sf 779 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/ruby
  2. # a(1) = 1; for n>1, a(n) = the largest prime divisor of the number C(n) formed from the concatenation of 1,2,3,... up to n.
  3. # https://oeis.org/A075022
  4. # First several terms of the sequence:
  5. # 1, 3, 41, 617, 823, 643, 9721, 14593, 3803, 1234567891, 630803, 2110805449, 869211457, 205761315168520219, 8230452606740808761, 1231026625769, 584538396786764503, 801309546900123763, 833929457045867563
  6. # a(n) = A006530(A007908(n)). - ~~~~
  7. # (PARI) a(n) = if(n==1, 1, vecmax(factor(eval(concat(apply(k->Str(k), [1..n]))))[, 1])); \\ ~~~~
  8. include("../../../factordb/auto.sf")
  9. func a(n) {
  10. 1..n -> to_a.join.to_i
  11. }
  12. var bfile = File("bfile.txt").open_w.autoflush(true)
  13. for n in (1..10000) {
  14. var row = "#{n} #{gpf(a(n))||1}"
  15. say row
  16. bfile.say(row)
  17. }