Sum of the digits of n is substring of n: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
(→{{header|Ruby}}: Add Ruby) |
||
Line 1,757: | Line 1,757: | ||
Found 48 numbers |
Found 48 numbers |
||
done... |
done... |
||
</pre> |
|||
=={{header|Ruby}}== |
|||
<syntaxhighlight lang="ruby">p (0...1000).select{|n| n.to_s.match? n.digits.sum.to_s} |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 109, 119, 129, 139, 149, 159, 169, 179, 189, 199, 200, 300, 400, 500, 600, 700, 800, 900, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 1000] |
|||
</pre> |
</pre> |
||