def is_palindromes?(n)
n.to_s == n.to_s.reverse
end
is_palindromes?(101)
true
def is_palindromes_by_double?(n)
n.to_s(2) == n.to_s(2).reverse
end
is_palindromes_by_double?(585)
true
results = []
(1..1_000_000).each do |n|
results << n if is_palindromes?(n) and is_palindromes_by_double?(n)
end
results
[1, 3, 5, 7, 9, 33, 99, 313, 585, 717, 7447, 9009, 15351, 32223, 39993, 53235, 53835, 73737, 585585]
results.inject *:+
872187