-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprog.sf
42 lines (32 loc) · 918 Bytes
/
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
#!/usr/bin/ruby
# a(n) is the smallest integer that has exactly n Lucas divisors (A000032).
# https://oeis.org/A356062
# Known terms:
# 1, 2, 4, 12, 36, 252, 2772, 52668, 1211364, 35129556, 1089016236, 44649665676, 2098534286772, 417608323067628, 88115356167269508, 24760415083002731748, 7948093241643876891108, 4140956578896459860267268
func a(n) {
return 2 if (n == 2)
var max = lcm(^n -> map{.lucas})
var arr = (0..Inf -> lazy.map{.lucas}.while { _ <= max }.grep{.divisors.count{.is_lucas} <= n})
var tt = Set(arr...)
for k in (arr) {
tt = tt.map { (_, lcm(_, k)) }.grep{ _ <= max }
}
tt.sort.first{.divisors.count{.is_lucas} == n}
}
for n in (1..20) {
say "a(#{n}) = #{a(n)}"
}
__END__
a(1) = 1
a(2) = 2
a(3) = 4
a(4) = 12
a(5) = 36
a(6) = 252
a(7) = 2772
a(8) = 52668
a(9) = 1211364
a(10) = 35129556
a(11) = 1089016236
a(12) = 44649665676
a(13) = 2098534286772