Prime triangle: Difference between revisions
m
Minor optimization to Rust code - see discussion page
m (Minor optimization to Java code - see discussion page) |
m (Minor optimization to Rust code - see discussion page) |
||
Line 931:
return is_prime(a[0] + a[1]);
}
for i in (1..a.len() - 1).step_by(2) {
if is_prime(a[0] + a[i]) {
a.swap(i, 1);
Line 950:
}
} else {
for i in (1..a.len() - 1).step_by(2) {
if is_prime(a[0] + a[i]) {
a.swap(i, 1);
Line 1,018:
1 1 1 1 1 2 4 7 24 80 216 648 1304 3392 13808 59448 155464 480728 1588162
Elapsed time:
</pre>
|