Extreme primes: Difference between revisions

Content added Content deleted
(→‎{{header|Go}}: Some changes as a result of changes to Go-rcu package.)
Line 173: Line 173:
"rcu"
"rcu"
)
)

func commatizeU64(n uint64) string {
s := fmt.Sprintf("%d", n)
if n < 0 {
s = s[1:]
}
le := len(s)
for i := le - 3; i >= 1; i -= 3 {
s = s[0:i] + "," + s[i:]
}
if n >= 0 {
return s
}
return "-" + s
}


func nextPrime(n *big.Int) *big.Int {
func nextPrime(n *big.Int) *big.Int {
Line 228: Line 213:
if m < 6 || m == 30 || m == 40 || m == 50 {
if m < 6 || m == 30 || m == 40 || m == 50 {
scount := rcu.Commatize(count)
scount := rcu.Commatize(count)
ssum := commatizeU64(sum.Uint64())
ssum := rcu.Commatize(sum.Uint64())
sp := commatizeU64(p.Uint64())
sp := rcu.Commatize(p.Uint64())
fmt.Printf("The %6sth extreme prime is: %18s for p <= %10s\n", scount, ssum, sp)
fmt.Printf("The %6sth extreme prime is: %18s for p <= %10s\n", scount, ssum, sp)
if m == 50 {
if m == 50 {