incorporated feedback on the java tutorial
This commit is contained in:
parent
90d6844b4a
commit
5e86f2ee81
4 changed files with 40 additions and 42 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 * math.pow(-1, i) / (2 * i + 1)
|
||||
acc += 4 * (1 - (i % 2) * 2) / (2 * i + 1)
|
||||
acc
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue