-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.sf
38 lines (29 loc) · 1.31 KB
/
prog.sf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/ruby
# a(1)=3, b(n) = Product_{k=1..n} a(k), a(n+1) is the largest prime factor of (b(n)-1).
# https://oeis.org/A005266
# First terms of the sequence:
# 2, 3, 7, 43, 139, 50207, 340999, 2365347734339, 4680225641471129, 1368845206580129, 889340324577880670089824574922371, 20766142440959799312827873190033784610984957267051218394040721
include('../../../factordb/auto.sf')
func a(n) is cached {
return 3 if (n == 1)
gpf(prod(1..^n, {|k| a(k) }) + 1)
}
for n in (1..20) {
say "#{n} #{a(n)}"
}
__END__
1 3
2 2
3 7
4 43
5 139
6 50207
7 340999
8 2365347734339
9 4680225641471129
10 1368845206580129
11 889340324577880670089824574922371
12 20766142440959799312827873190033784610984957267051218394040721
13 3486546133523738294549021453705017008734873145092643149204854821614266466998637603378972254923344607825545244648001799
14 26402590817665123115124196783110486814361930234455788059710183484151247460960172672371287819122033451
not FF: 110721465493002960453669737626182095929861002444217630084728101840814389517145776947757647185681033716504925247273515756720076434129863468366272908514227824139272687809696635619251625371039464763992521352908321920697230358329690909804157733806149260259095949192261207550664145547314786038676638526563069026548149264840040649770821659684890735628731429655066437369046403043