123456789101112131415161718192021 |
- #!/usr/bin/ruby
- # Daniel "Trizen" Șuteu
- # https://github.com/trizen
- # Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
- # https://projecteuler.net/problem=36
- # Runtime: 3.153s
- var sum = 0
- 1e6.times {|n|
- if (n.is_palindrome && n.is_palindrome(2)) {
- sum += n
- }
- }
- say sum
|