Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,17 @@
fn main() {
let limit = 500;
let column_w = limit.to_string().len() + 1;
let mut pms = Vec::with_capacity(limit / 2 - limit / 3 / 2 - limit / 5 / 3 / 2 + 1);
let mut count = 0;
for u in (2..3).chain((3..limit).step_by(2)) {
if pms.iter().take_while(|&&p| p * p <= u).all(|&p| u % p != 0) {
pms.push(u);
let dgs = std::iter::successors(Some(u), |&n| (n > 9).then(|| n / 10)).map(|n| n % 10);
if pms.binary_search(&dgs.sum()).is_ok() {
print!("{}{u:column_w$}", if count % 10 == 0 { "\n" } else { "" });
count += 1;
}
}
}
println!("\n---\nFound {count} additive primes less than {limit}");
}

View file

@ -0,0 +1,19 @@
// [dependencies]
// primal = "0.3.0"
fn sum_digits(u: usize) -> usize {
std::iter::successors(Some(u), |&n| (n > 9).then(|| n / 10)).fold(0, |s, n| s + n % 10)
}
fn main() {
let limit = 500;
let column_w = limit.to_string().len() + 1;
let sieve_primes = primal::Sieve::new(limit);
let count = sieve_primes
.primes_from(2)
.filter(|&p| p < limit && sieve_primes.is_prime(sum_digits(p)))
.zip(["\n"].iter().chain(&[""; 9]).cycle())
.inspect(|(u, sn)| print!("{sn}{u:column_w$}"))
.count();
println!("\n---\nFound {count} additive primes less than {limit}");
}