Sum of square and cube digits of an integer are primes: Difference between revisions
Sum of square and cube digits of an integer are primes (view source)
Revision as of 14:46, 27 March 2023
, 1 year ago→{{header|Ruby}}: Add Ruby
(→{{header|QuickBASIC}}: Added a solution.) |
(→{{header|Ruby}}: Add Ruby) |
||
Line 928:
</pre>
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">require 'prime'
p (1..100).select{|n|(n*n).digits.sum.prime? && (n**3).digits.sum.prime?}</syntaxhighlight>
{{out}}
<pre>
[16, 17, 25, 28, 34, 37, 47, 52, 64]
</pre>
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">1..99 -> grep { .square.digits_sum.is_prime && .cube.digits_sum.is_prime }.say</syntaxhighlight>
|