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

Content added Content deleted
(Added Wren)
Line 36:
Found 33 numbers
done...
</pre>
 
=={{header|Wren}}==
{{libheader|Wren-math}}
{{libheader|Wren-trait}}
{{libheader|Wren-seq}}
{{libheader|Wren-fmt}}
<lang ecmascript>import "/math" for Int
import "/trait" for Stepped
import "/seq" for Lst
import "/fmt" for Fmt
 
var primes = []
for (seq in [ 3..3, 33..33, Stepped.new(303..393, 10), Stepped.new(3003..3993, 10) ]) {
for (e in seq) if (Int.isPrime(e)) primes.add(e)
}
System.print("Primes under 4,000 which begin and end in 3:")
for (chunk in Lst.chunks(primes, 11)) Fmt.print("$,5d", chunk)
System.print("\nFound %(primes.count) such primes.")</lang>
 
{{out}}
<pre>
Primes under 4,000 which begin and end in 3:
3 313 353 373 383 3,023 3,083 3,163 3,203 3,253 3,313
3,323 3,343 3,373 3,413 3,433 3,463 3,533 3,583 3,593 3,613 3,623
3,643 3,673 3,733 3,793 3,803 3,823 3,833 3,853 3,863 3,923 3,943
 
Found 33 such primes.
</pre>