(1..100).select { |n| p n if ('1' * n) !~ /^1?$|^(11+?)\1+$/ }
Basically, the /^(11+?)\1+$/ part checks if the 1-string can be factorized. See Avinash Meetoo.
(1..100).select { |n| p n if ('1' * n) !~ /^1?$|^(11+?)\1+$/ }
Basically, the /^(11+?)\1+$/ part checks if the 1-string can be factorized. See Avinash Meetoo.