-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.sf
32 lines (23 loc) · 1.38 KB
/
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
#!/usr/bin/ruby
# Search for numbers k such that lcm({p-1}) and lcm({p+1}) are both small, where p are prime factor of k.
# See also:
# https://oeis.org/A334151
var min = Inf
for k in (1..1e7) {
k.is_odd || next
k.is_composite || next
k.is_squarefree || next
var a = k.factor.lcm{.dec}
var b = k.factor.lcm{.inc}
var r = ((a+b) / k)
if (r < min) {
min = r
print(k, ", ")
}
}
__END__
1, 3, 7, 15, 19, 31, 49, 99, 127, 241, 449, 511, 577, 703, 769, 799, 1249, 2177, 2889, 3401, 3725, 4351, 4751, 4801, 6049, 8191, 19601, 21295, 51841, 95831, 143749, 456191, 721279, 1062881, 1431431, 1623601, 1885521, 2101249, 3543121, 6215749,
1, 4, 8, 16, 27, 32, 64, 128, 243, 256, 512, 1024, 2048, 4096, 6561, 8192, 16384, 32768, 59049, 65536, 131072, 262144, 524288, 1048576,
1, 9, 25, 27, 75, 81, 225, 243, 625, 729, 2025, 2187, 6075, 6561, 15625, 19683, 50421, 59049, 151263, 177147, 390625, 531441, 1361367, 1594323, 4084101,
1, 10, 21, 30, 66, 110, 165, 210, 330, 651, 966, 1155, 1785, 1870, 2046, 2255, 2310, 3570, 4290, 4510, 4774, 5610, 6765, 7161, 10230, 11935, 13530, 14322, 23870, 35178, 35805, 58630, 71610, 175890, 410410, 615615,
15, 21, 55, 85, 105, 165, 399, 651, 1155, 1785, 2145, 2255, 2387, 2805, 5115, 6765, 7161, 11935, 17589, 29315, 35805, 87945, 205205, 498355, 508431, 608685, 615615, 1495065, 2378145, 2542155, 3488485, 3816813, 5775495, 6361355,