Skip to main content
1 of 4
br3nt
  • 161
  • 4

Ruby: 35 bytes

->(s,m){(0...s*s).map{|v|m**v}.sum}

Test:

f = ->(s,m){(0...s*s).map{|v|m**v}.sum}

f[8,2]   # 18446744073709551615
f[3,6]   # 2015539
f[7,1.5] # 850161998.2853994
f[5,-3]  # 211822152361
f[256,1] # 65536
f[2,2]   # 15
f[2,-2]  # -5
br3nt
  • 161
  • 4