Primes with digits in nondecreasing order: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
Line 1,363: Line 1,363:
Found 50 base 10 primes with digits in nondecreasing order
Found 50 base 10 primes with digits in nondecreasing order
done...</pre>
done...</pre>

=={{header|Ruby}}==
<syntaxhighlight lang="ruby">require 'prime'

base = 10
upto = 1000

res = Prime.each(upto).select do |pr|
pr.digits(base).each_cons(2).all?{|p1, p2| p1 >= p2}
end

puts "There are #{res.size} non-descending primes below #{upto}:"
puts res.join(", ")
</syntaxhighlight>
{{out}}
<pre>There are 50 non-descending primes below 1000:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 37, 47, 59, 67, 79, 89, 113, 127, 137, 139, 149, 157, 167, 179, 199, 223, 227, 229, 233, 239, 257, 269, 277, 337, 347, 349, 359, 367, 379, 389, 449, 457, 467, 479, 499, 557, 569, 577, 599, 677
</pre>


=={{header|Seed7}}==
=={{header|Seed7}}==