Jump to content

Smarandache prime-digital sequence: Difference between revisions

m (Convert to a task.)
(→‎{{header|Ruby}}: Added Ruby)
Line 689:
</pre>
 
=={{header|Ruby}}==
Attaching 3 and 7 to permutations of 2,3,5 and 7
<lang ruby>require "prime"
smarandache = Enumerator.new do|y|
prime_digits = [2,3,5,7]
prime_digits.each{|pr| y << pr} # yield the below-tens
(1..).each do |n|
prime_digits.repeated_permutation(n).each do |perm|
c = perm.join.to_i * 10
y << c + 3 if (c+3).prime?
y << c + 7 if (c+7).prime?
end
end
end
 
seq = smarandache.take(100)
p seq.first(25)
p seq.last
</lang>
{{out}}
<pre>[2, 3, 5, 7, 23, 37, 53, 73, 223, 227, 233, 257, 277, 337, 353, 373, 523, 557, 577, 727, 733, 757, 773, 2237, 2273]
33223
</pre>
=={{header|Sidef}}==
<lang ruby>func is_prime_digital(n) {
1,149

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.