-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.sf
60 lines (50 loc) · 1.02 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/ruby
# Smallest prime divisor of A000058(n) = A007018(n) + 1 (Sylvester's sequence).
# https://oeis.org/A323605
# See also:
# https://en.wikipedia.org/wiki/Sylvester%27s_sequence#Divisibility_and_factorizations
# a(13) <= 2589377038614498251653
# a(13) <= 2872413602289671035947763837
# Are all the terms in Sylvester's sequence squarefree?
func f((0)) { 1 }
func f(n) is cached {
f(n-1)**2 + f(n-1)
#a(n) = a(n-1)^2 + a(n-1), a(0)=1.
}
#say (f(12)+1 % 2589377038614498251653)
var t = 0
for k in (0..30) {
var n = f(k)+1
say (++t, '-> ', n.trial_factor(1e8).first(-1))
}
__END__
1-> []
2-> []
3-> []
4-> []
5-> [13]
6-> []
7-> [547, 607, 1033]
8-> [29881, 67003, 9119521]
9-> []
10-> [181, 1987]
11-> [2287, 2271427]
12-> [73]
13-> []
14-> [52387, 5020387]
15-> [13999, 74203, 9638659, 57218683]
16-> [17881]
17-> [128551]
18-> [635263, 1286773, 21269959]
19-> []
20-> []
21-> [352867]
22-> []
23-> []
24-> [74587]
25-> []
26-> []
27-> [27061]
28-> [164299, 3229081]
29-> [20929]
30-> [1171, 298483, 97562299]