Fixed problem in Pi calculation algorithm
This commit is contained in:
parent
06c134ca91
commit
2770f47f27
6 changed files with 17 additions and 19 deletions
|
|
@ -59,7 +59,7 @@ object Pi extends App {
|
|||
def calculatePiFor(start: Int, nrOfElements: Int): Double = {
|
||||
var acc = 0.0
|
||||
for (i <- start until (start + nrOfElements))
|
||||
acc += 4 * (1 - (i % 2) * 2) / (2 * i + 1)
|
||||
acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1)
|
||||
acc
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue