Sha256: e49d250d0cd6a869e6e3726cbad52a8c286fc22f76e03d7c61dc145b1b4e29f2
Contents?: true
Size: 288 Bytes
Versions: 41
Compression:
Stored size: 288 Bytes
Contents
import scala.math.pow class Squares { def sumOfSquares(n: Int): Int = n * (n + 1) * (2 * n + 1) / 6 def squareOfSums(n: Int): Int = pow((n * (n + 1) / 2), 2).toInt def difference(n: Int): Int = squareOfSums(n) - sumOfSquares(n) } object Squares { def apply() = new Squares }
Version data entries
41 entries across 41 versions & 1 rubygems