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

Version Path
trackler-2.2.1.78 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.77 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.76 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.75 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.74 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.73 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.72 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.71 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.70 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.69 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.68 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.67 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.66 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.65 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.64 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.63 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.62 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.61 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.60 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.59 tracks/nim/exercises/difference-of-squares/example.nim