-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.sf
69 lines (51 loc) · 1.09 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
64
65
66
67
68
69
#!/usr/bin/ruby
# a(1) = 1; a(n) is the smallest positive number that has yet appeared such that the sum of all terms a(1) + ... + a(n) has the same number of prime factors, counted with multiplicity, as the product of all terms a(1) * ... * a(n).
# https://oeis.org/A364140
# This approach is quite slow...
var seen = Set(1)
var bo = 0
loop {
var min = Inf
var t = seen.prod
var u = seen.sum
func generate(j) {
var lo = 1
var hi = 2*lo
var b = bo+j
loop {
if (lo > min) {
return nil
}
j.almost_primes(lo, hi).each {|w|
if ((u+w -> is_almost_prime(b)) && !seen.has(w)) {
return w
}
}
lo = hi+1
hi *= 2
}
}
var k = -1
for i in (1..Inf) {
if (2**i > min) {
break
}
var s = generate(i) \\ next
if (s < min) {
k = s
min = s
}
}
bo += k.bigomega
say k
seen << k
}
__END__
2
3
10
227
77
16064
33464399
8113