Smarandache-Wellin primes: Difference between revisions
Content added Content deleted
(→{{header|C}}: Changed in line with Wren solution of which it is a translation.) |
(→{{header|Go}}: Corrected ordinal number display.) |
||
Line 178: | Line 178: | ||
"strings" |
"strings" |
||
) |
) |
||
func ord(count int) string { |
|||
if count == 1 { |
|||
return "st" |
|||
} |
|||
if count == 2 { |
|||
return "nd" |
|||
} |
|||
if count == 3 { |
|||
return "rd" |
|||
} |
|||
return "th" |
|||
} |
|||
func main() { |
func main() { |
||
Line 196: | Line 209: | ||
sws = sws[0:20] + "..." + sws[le-20:le] |
sws = sws[0:20] + "..." + sws[le-20:le] |
||
} |
} |
||
fmt.Printf("% |
fmt.Printf("%d%s: index %4d digits %4d last prime %5d -> %s\n", count, ord(count), i+1, len(sw), primes[i], sws) |
||
} |
} |
||
i++ |
i++ |
||
Line 219: | Line 232: | ||
if n.ProbablyPrime(15) { |
if n.ProbablyPrime(15) { |
||
count++ |
count++ |
||
fmt.Printf("% |
fmt.Printf("%2d%s: index %4d prime %v\n", count, ord(count), i+1, n) |
||
} |
} |
||
i++ |
i++ |
||
Line 228: | Line 241: | ||
<pre> |
<pre> |
||
The known Smarandache-Wellin primes are: |
The known Smarandache-Wellin primes are: |
||
1st: index 1 digits 1 last prime 2 -> 2 |
|||
2nd: index 2 digits 2 last prime 3 -> 23 |
|||
3rd: index 4 digits 4 last prime 7 -> 2357 |
|||
4th: index 128 digits 355 last prime 719 -> 23571113171923293137...73677683691701709719 |
4th: index 128 digits 355 last prime 719 -> 23571113171923293137...73677683691701709719 |
||
5th: index 174 digits 499 last prime 1033 -> 23571113171923293137...10131019102110311033 |
5th: index 174 digits 499 last prime 1033 -> 23571113171923293137...10131019102110311033 |
||
Line 238: | Line 251: | ||
The first 20 Derived Smarandache-Wellin primes are: |
The first 20 Derived Smarandache-Wellin primes are: |
||
1st: index 32 prime 4194123321127 |
|||
2nd: index 72 prime 547233879626521 |
|||
3rd: index 73 prime 547233979727521 |
|||
4th: index 134 prime 13672766322929571043 |
4th: index 134 prime 13672766322929571043 |
||
5th: index 225 prime 3916856106393739943689 |
5th: index 225 prime 3916856106393739943689 |