-
Notifications
You must be signed in to change notification settings - Fork 0
/
binary_search.sf
37 lines (31 loc) · 1.29 KB
/
binary_search.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
#!/usr/bin/ruby
# a(n) is the largest nonnegative integer m such that m >= pi(m)^(1 + 1/n).
# https://oeis.org/A334598
func pi(x) {
Num(`/tmp/primecount #{x}`)
}
assert_eq(pi(100), 25)
var n = 9
say bsearch_ge(2272946110443506, 2272947466750194, {|k|
say "Testing: #{k}"
pi(k)**(1 + 1/n) <=> k
})
__END__
1557 < a(3) < 2106
146550 < a(4) < 150837
12742472 < a(5) < 12808054
1221624448 < a(6) < 1222129931
132658777685 < a(7) < 132667622418
16354815291065 < a(8) < 16354921734869
2272946110443506 < a(9) < 2272947466750194
353076153013769669 < a(10) < 353076171214205777
60799055701509956719 < a(11) < 60799076382017825067
11518835895999279011732 < a(12) < 11518836276046167445699
2385009478248632340462665 < a(13) < 2385009485384492495811074
536478691978446884022014836 < a(14) < 536492475675414328476729271
130411747286018644769576971362 < a(15) < 130414492089146845833864222770
34098740440473051614027739794760 < a(16) < 34099336754743759167110821274342
9549883596287176881971866353026188 < a(17) < 9550024079823418958333043926672872
2854069254825491474720771242628651215 < a(18) < 2854104954913272545098127276381764169
907127166553460837050896505170554295736 < a(19) < 907136907295970838691088566994317991950
305688995977730841912704211976764954028831 < a(20) < 305691837881564449566259516315272423981568