063 Powerful digit counts.sf 286 B

123456789101112131415161718192021
  1. #!/usr/bin/ruby
  2. # Daniel "Trizen" Șuteu
  3. # License: GPLv3
  4. # Date: 28 January 2017
  5. # https://github.com/trizen
  6. # https://projecteuler.net/problem=63
  7. # Runtime: 0.158s
  8. var count = 0
  9. for n in (1 .. 9) {
  10. for p in (1 .. 3*n) {
  11. n**p -> len == p && ++count
  12. }
  13. }
  14. say count