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.159 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.158 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.157 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.156 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.155 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.154 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.153 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.152 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.151 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.150 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.149 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.148 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.147 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.146 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.145 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.144 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.143 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.142 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.141 tracks/nim/exercises/difference-of-squares/example.nim
trackler-2.2.1.140 tracks/nim/exercises/difference-of-squares/example.nim