Prime numbers which contain 123: Difference between revisions
Content added Content deleted
(→{{header|Wren}}: Rejigged to deal with stretch goal.) |
(→{{header|Go}}: Rejigged to deal with stretch goal.) |
||
Line 21: | Line 21: | ||
func main() { |
func main() { |
||
limit := 100_000 |
|||
primes := rcu.Primes(limit) |
primes := rcu.Primes(limit * 10) |
||
var results []int |
var results []int |
||
for _, p := range primes { |
for _, p := range primes { |
||
if p < 1000 { |
if p < 1000 || p > 99999 { |
||
continue |
continue |
||
} |
} |
||
Line 41: | Line 41: | ||
} |
} |
||
} |
} |
||
fmt.Println("\n\nFound", len(results), "such primes.") |
fmt.Println("\n\nFound", len(results), "such primes under", climit, "\b.") |
||
limit = 1_000_000 |
|||
climit = rcu.Commatize(limit) |
|||
count := len(results) |
|||
for _, p := range primes { |
|||
if p < 100_000 { |
|||
continue |
|||
} |
|||
ps := fmt.Sprintf("%s", p) |
|||
if strings.Contains(ps, "123") { |
|||
count++ |
|||
} |
|||
} |
|||
fmt.Println("\nFound", count, "such primes under", climit, "\b.") |
|||
}</lang> |
}</lang> |
||
Line 53: | Line 67: | ||
76,123 81,233 81,239 89,123 91,237 98,123 |
76,123 81,233 81,239 89,123 91,237 98,123 |
||
Found 46 such primes. |
Found 46 such primes under 100,000. |
||
Found 451 such primes under 1,000,000. |
|||
</pre> |
</pre> |
||