048 Self powers.sf 344 B

123456789101112131415161718192021
  1. #!/usr/bin/ruby
  2. # Author: Daniel "Trizen" Șuteu
  3. # License: GPLv3
  4. # Website: https://github.com/trizen
  5. # Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
  6. # https://projecteuler.net/problem=48
  7. # Runtime: 0.209s
  8. var mod = 10**10
  9. var sum = Mod(0, mod)
  10. for i in (1..1000) {
  11. sum += Mod(i, mod)**i
  12. }
  13. say sum.lift