Fix subtraction overflow.

This commit is contained in:
2025-12-05 14:29:06 +01:00
parent 91c9eaf1b9
commit 97d756bab4

View File

@@ -76,12 +76,14 @@ fn main() {
arr[n2] = !arr[n2]; arr[n2] = !arr[n2];
} }
if x > y {
let n3 = ((3 * x * x) - (y * y)) as usize; let n3 = ((3 * x * x) - (y * y)) as usize;
if x > y && n3 <= (opts.num as usize) && n3 % 12 == 11 { if n3 <= (opts.num as usize) && n3 % 12 == 11 {
arr[n3] = !arr[n3]; arr[n3] = !arr[n3];
} }
} }
} }
}
for i in 5..=(f64::sqrt(opts.num as f64) as u64 + 1) as usize { for i in 5..=(f64::sqrt(opts.num as f64) as u64 + 1) as usize {
if !arr[i as usize] { if !arr[i as usize] {