Smarandache prime-digital sequence: Difference between revisions

Added Wren
(C, C++ and Rust examples made a bit more ambitious)
(Added Wren)
Line 1,538:
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|Wren}}==
{{libheader|Wren-math}}
Simple brute-force approach.
<lang ecmascript>import "/math" for Int
 
var limit = 1000
var spds = List.filled(limit, 0)
spds[0] = 2
var i = 3
var count = 1
while (count < limit) {
if (Int.isPrime(i)) {
var digits = i.toString
if (digits.all { |d| "2357".contains(d) }) {
spds[count] = i
count = count + 1
}
}
i = i + 2
if (i > 10) {
var j = i % 10
if (j == 1 || j == 5) {
i = i + 2
} else if (j == 9) {
i = i + 4
}
}
}
System.print("The first 25 SPDS primes are:")
System.print(spds.take(25).toList)
System.print("\nThe 100th SPDS prime is %(spds[99])")
System.print("\nThe 1,000th SPDS prime is %(spds[999])")</lang>
 
{{out}}
<pre>
The first 25 SPDS primes are:
[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]
 
The 100th SPDS prime is 33223
 
The 1,000th SPDS prime is 3273527
</pre>
 
9,482

edits