1234567891011121314151617181920212223242526 |
- #!/usr/bin/ruby
- # 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.
- # https://oeis.org/A075022
- # First several terms of the sequence:
- # 1, 3, 41, 617, 823, 643, 9721, 14593, 3803, 1234567891, 630803, 2110805449, 869211457, 205761315168520219, 8230452606740808761, 1231026625769, 584538396786764503, 801309546900123763, 833929457045867563
- # a(n) = A006530(A007908(n)). - ~~~~
- # (PARI) a(n) = if(n==1, 1, vecmax(factor(eval(concat(apply(k->Str(k), [1..n]))))[, 1])); \\ ~~~~
- include("../../../factordb/auto.sf")
- func a(n) {
- 1..n -> to_a.join.to_i
- }
- var bfile = File("bfile.txt").open_w.autoflush(true)
- for n in (1..10000) {
- var row = "#{n} #{gpf(a(n))||1}"
- say row
- bfile.say(row)
- }
|