Smarandache-Wellin primes
say "Smarandache-Wellen primes:"
for (var (p=2, i=1, n='', nth=1); nth <= 8; (p.next_prime!, ++i)) {
n += Str(p)
if (Num(n).is_prime){
var t = n
if (t.len > 50) {
t = (t.first(20) + ' ... ' + t.last(20) + " (#{t.len} digits)")
}
printf("%s: Index:%5d Last prime:%6d S-W: %s\n", nth, i, p, t)
++nth
}
}
say "\nSmarandache-Wellen derived primes:"
func derived(String n) -> String {
var freq = n.chars.freq
0..9 -> map { freq{_} \\ 0 }.join
}
for (var (p=2, i=1, nth=1, n=''); nth <= 20; (p.next_prime!, ++i)) {
n += Str(p)
var t = derived(n)
if (Num(t).is_prime){
if (t.len > 50) {
t = (t.first(20) + ' ... ' + t.last(20) + " (#{t.len} digits)")
}
printf("%2s: Index:%5d %s\n", nth, i, t)
++nth
}
}Output:
Last updated
Was this helpful?