Primes whose first and last number is 3: Difference between revisions

No edit summary
Line 947:
</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">require 'prime'
 
puts "Primes below #{n=4000} which start and end with #{d=3}: "
p Prime.each(n).select{|pr| p_d = pr.digits; p_d.first == d && p_d.last == d}
 
print "\nCount of primes below #{n=1_000_000} which start and en with #{d=3}: "
puts Prime.each(n).count{|pr| p_d = pr.digits; p_d.first == d && p_d.last == d}
</syntaxhighlight>
{{out}}
<pre>Primes below 4000 which start and end with 3:
[3, 313, 353, 373, 383, 3023, 3083, 3163, 3203, 3253, 3313, 3323, 3343, 3373, 3413, 3433, 3463, 3533, 3583, 3593, 3613, 3623, 3643, 3673, 3733, 3793, 3803, 3823, 3833, 3853, 3863, 3923, 3943]
 
Count of primes below 1000000 which start and en with 3: 2251
</pre>
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">func numbers_with_edges(upto, base = 10, s = [3]) {
1,149

edits