-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprog.sf
130 lines (100 loc) · 2.01 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/ruby
# Conjecture: partial sums of A298826. (with changed sign for each second term)
# a(n) = Sum_{k=1..n} A174863(floor(n/k)).
# a(n) = Sum_{k=1..n} Sum_{d|k} (-1)^omega(d).
# a(n) = Sum_{k=1..n} (-1)^omega(k) * floor(n/k).
# Conjecture: a(n) = Sum_{k=1..n} (-1)^(k+1) * A298826(k).
# Terms:
# 1, 1, 1, 0, 0, 0, 0, -2, -3, -3, -3, -3, -3, -3, -3, -6, -6, -6, -6, -6, -6, -6, -6, -6, -7, -7, -9, -9, -9, -9, -9, -13, -13, -13, -13, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13, -13
# OEIS:
# https://oeis.org/A298826 -- a(n) = A298825(n)/n.
# https://oeis.org/A174863 -- Little omega analog to Liouville's function L(n).
# https://oeis.org/A306408 -- a(n) = Sum_{d|n} (-1)^omega(n/d) * d.
func f(n) {
n.divisors.sum{|d|
(-1)**omega(d)
}
}
func A174863(n) {
sum(1..n, {|k|
(-1)**omega(k)
})
}
func a(n) {
sum(1..n, {|k|
A174863(floor(n/k))
})
}
func a2(n) {
sum(1..n, {|k|
f(k)
})
}
func a3(n) {
sum(1..n, {|k|
(-1)**omega(k) * floor(n/k)
})
}
say 30.of(a)
say 30.of(a2)
say 30.of(a3)
__END__
func f2(n) {
sum(1..n, {|k|
(-1)**omega(k) * floor(n/k)
})
}
say 100.of(f2).map_cons(2,{|a,b| b-a })
__END__
#say 20.of(f2).accumulate
500.of(f2).each{|k|
say k
}
__END__
#say 200.of(f2)
func a(n) {
#~ n.factor_prod{|p,e|
#~ p**e - (p**e - 1)/(p-1)
#~ }
1..n -> sum{|k|
#k.moebius
(-1)**omega(k)
}
}
func b(n) {
n * n.divisors.sum{|d|
(-1)**(bigomega(d) - omega(d)) / d
}
}
func c(n) {
n * n.divisors.sum{|d|
(-1)**bigomega(d) / d
}
}
say 20.of(a)
say 20.of(b)
say 20.of(c)
func f(n) {
sum(1..n, {|k|
a(floor(n/k))
})
}
func g(n) {
sum(1..n, {|k|
b(floor(n/k))
})
}
func h(n) {
sum(1..n, {|k|
c(floor(n/k))
})
}
say ''
say 20.of(f)
say 20.of(g)
say 20.of(h)
#say f(1000)
#say f(1000)
#say sum(1..1000, {|d|
# d.sigma0
#})