123456789101112131415161718192021 |
- #!/usr/bin/ruby
- # Author: Trizen
- # License: GPLv3
- # Website: https://github.com/trizen
- # Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.
- # https://projecteuler.net/problem=52
- # Runtime: 8.214s (previously: 9.650s)
- var x = 1
- loop {
- if ([String(2*x), String(3*x), String(4*x), String(5*x), String(6*x)].map{.sort}.join ~~ /^(\d+)\1{4}$/) {
- say x
- break
- }
- ++x
- }
|