Реализации алгоритмов/Решето Аткина: различия между версиями

м
// Просеивание:
// n = 4x² + y²
n = (x2 << 2u642) + y2;
if n <= limit as u64 && (n % 12u6412 == 1u641 || n % 12u6412 == 5u645) {
item = sieve[n as usize];
sieve.set(n as usize, !item);
// n = 3x² + y²
n -= x2;
if n <= limit as u64 && n % 12u6412 == 7u647 {
item = sieve[n as usize];
sieve.set(n as usize, !item);
// n = 3x² - y² (при x > y)
if x2 > y2 {
n -= y2 << 1u641;
if n <= limit as u64 && n % 12u6412 == 11u6411 {
item = sieve[n as usize];
sieve.set(n as usize, !item);
}
y2 += dy2;
dy2 += 2u642;
}
x2 += dx2;
dx2 += 2u642;
}
}
let mut r = 5u32;
let mut r2 = (r * r) as u64;
let mut dr2 = (r << 1u321) as u64 + 1u641;
while r2 < limit as u64 {
if sieve[r as usize] {
}
}
r += 1u321;
r2 += dr2;
dr2 += 2u642;
}
}
// 2 и 3 — заведомо простые
if limit > 2u322 {
sieve.set(2, true);
}
if limit > 3u323 {
sieve.set(3, true);
}
74

правки