-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprog.sf
63 lines (48 loc) · 1.22 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
61
62
63
#!/usr/bin/ruby
# Least number k > 0 such that the numerator of Sum_{i=1..k} 1/prime(i)^n is a prime.
# https://oeis.org/A126225
# a(11) >= 1019
# a(12) >= 273
func a(n) {
var sum = 0
for k in (1..1e6) {
sum += (1 / prime(k)**n)
var num = sum.nu
var size = num.ilog10
if (k < 1019) {
next
}
say "[#{n}] Testing: #{k} -- #{size}"
if (size > 5000) {
if (num.trial_factor(1e6).len > 1) {
say "1e6 - factor"
next
}
if (num.trial_factor(1e7).len > 1) {
say "1e7 - factor"
next
}
if (num.trial_factor(1e8).len > 1) {
say "1e8 - factor"
next
}
}
if (size > 20_000) {
if (num.trial_factor(2e8).len > 1) {
say "2e8 - factor"
next
}
if (num.trial_factor(3e8).len > 1) {
say "3e8 - factor"
next
}
}
say "- primality test"
if (num.is_prob_prime) {
die "\nFound: #{k}\n"
#return k
}
}
}
var k = 11
say [k, a(k)]