Sha256: 6dc379198b475c5a68cee18ea5c45fee94d356dd4833ca8ef5ed4db83c21d82f
Contents?: true
Size: 487 Bytes
Versions: 396
Compression:
Stored size: 487 Bytes
Contents
struct Squares { var max = 1 init (_ max: Int) { if max > 0 { self.max = max } } var squareOfSums: Int { let numbers = Array(1...self.max) let sum = numbers.reduce(0, + ) return sum * sum } var sumOfSquares: Int { let numbers = Array(1...self.max) return numbers.map { return $0*$0 }.reduce(0, + ) } var differenceOfSquares: Int { return squareOfSums - sumOfSquares } }
Version data entries
396 entries across 396 versions & 1 rubygems