Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
integer powers of 2 which are palindromes
[system] ~
$ irb
irb(main):001:0> (0..10**4).each do |n|
irb(main):002:1* p = 2 ** n
irb(main):003:1> puts p if p.to_s == p.to_s.reverse
irb(main):004:1> end
1
2
4
8
=> 0..10000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment