-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprog.sf
43 lines (34 loc) · 798 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
43
#!/usr/bin/ruby
# The number of terms of A354558 that are <= 10^n.
# https://oeis.org/A354559
# Known terms:
# 1, 2, 5, 13, 28, 79, 204, 549, 1509, 4231, 12072, 36426, 112589
func a(n) {
var k = 10**n
#var smooth = []
var count = 0
var primes = []
k.isqrt.each_prime {|p|
var pp = p*p
primes << p
#smooth << smooth_numbers(idiv(k, pp), p.primes).map{_ * pp}...
count += smooth_numbers(idiv(k, pp), primes).map{_ * pp}.count { .inc.gpf.sqr `divides` .inc }
}
#smooth.grep{.inc.gpf.sqr `divides` .inc}
#smooth.count{.inc.gpf.sqr `divides` .inc}
return count
}
for n in (1..15) {
say "a(#{n}) = #{a(n)}"
}
__END__
a(1) = 1
a(2) = 2
a(3) = 5
a(4) = 13
a(5) = 28
a(6) = 79
a(7) = 204
a(8) = 549
a(9) = 1509
a(10) = 4231