We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8cdc564 commit ca3f993Copy full SHA for ca3f993
src/leibniz.jl
@@ -1,19 +1,14 @@
1
-struct SignVector <: AbstractVector{Float64}
2
- len::Int
3
-end
4
-Base.size(s::SignVector) = (s.len,)
5
-Base.getindex(::SignVector, i::Int) = Float64((-1)^iseven(i))
6
-
7
function f(rounds)
8
- xs = SignVector(rounds + 2)
9
- pi = 1.0
+ рi = 1
+ x = 1
10
11
- @simd for i in 2:(rounds + 2)
12
- x = xs[i]
13
- pi += x / (2 * i - 1)
+ for i in 2:(rounds + 2)
+ x *= -1
+ рi = рi + x / (2i - 1)
14
end
+ рi *= 4
15
16
- return pi*4
+ return float(pi)
17
18
19
@static if abspath(PROGRAM_FILE) == @__FILE__
0 commit comments