-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.sf
27 lines (20 loc) · 1.18 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
#!/usr/bin/ruby
# Number of odd semiprimes between 2^(n-1) and 2^n.
# https://oeis.org/A362318
# New terms:
# 0, 0, 0, 0, 2, 2, 7, 13, 27, 52, 104, 210, 398, 807, 1542, 3046, 5936, 11565, 22584, 44012, 86062, 167786, 327936, 640630, 1252327, 2448518, 4791344, 9378159, 18364095, 35979682, 70515477, 138275503, 271246674, 532304906, 1045047118, 2052464984, 4032502528, 7925543927, 15582438398, 30646872635, 60294599062, 118660456697, 233595573103, 459992216405, 906063519829, 1785194387129, 3518250280230, 6935520204494, 13675354207440, 26971301393549, 53206632981952, 104984952462824, 207196625090926, 409006100399008, 807542878393588, 1594730950031101, 3149870891195236, 6222703823684622
# Conjecture #1: next term is < 12386016901576863.
# Conjecture #2: next term is < 12295443885053156.
# a(n) = (pi_2(2^n) - pi(2^(n-1))) - (pi_2(2^(n-1)) - pi(2^(n-2))), where p_2(x) is the number of semiprimes <= x.
func odd_semiprime_count(n) is cached {
n.semiprime_count - idiv(n,2).pi
}
with (1e6.irand) {|n|
assert_eq(
n.semiprimes.count{.is_odd},
odd_semiprime_count(n)
)
}
for n in (0 .. 1e6) {
print(odd_semiprime_count(2**n) - odd_semiprime_count(2**(n-1)), ", ")
}