Slide 10
Slide 10 text
Split up the factorial function
def partialFactorial(low: Int, high: Int): BigInt = {
@annotation.tailrec
def recurse(
low: Int, high: Int, acc: BigInt
): BigInt = {
if(low <= high)
recurse(low, high - 1, high * acc)
else acc
}
recurse(low, high, 1)
}
def identity: BigInt = 1
def sync(n: Int): BigInt = {
getBuckets(n).
foldLeft(identity){(acc, bounds) =>
partialFactorial(bounds._1, bounds._2) * acc
}
}
Takes 10k at a time,
trust me ^_^!
@dreadedsoftware | @integrichain