Sha256: 4ecb12251ca8b38c378f163c5872e254046a189b64d3cb58590ba7d2cb084c3e
Contents?: true
Size: 319 Bytes
Versions: 376
Compression:
Stored size: 319 Bytes
Contents
proc `**`(base, exponent: int): int = var power = 1 for i in 1..exponent: power *= base power proc square_of_sum*(n: int): int = (n * (n + 1) div 2) ** 2 proc sum_of_squares*(n: int): int = (n * (n + 1) * ((2 * n) + 1)) div 6 proc difference*(n: int): int = abs(sum_of_squares(n) - square_of_sum(n))
Version data entries
376 entries across 376 versions & 1 rubygems