Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7995

Other • Re: new docker image drop

$
0
0
A digitally delicate (or weakly prime) number is a prime number that becomes composite if any one of its digits is replaced by any other digit. Essentially, it is a prime that is "surrounded" by composite numbers in the digital space
Computing 'Weakly Primes'

Code:

 podman  run --rm --platform linux/arm64 --network=slirp4netns -it n4jm4/raspberry-pi-os bash

Code:

   apt update   apt install nano pari-gp fastfetch   nano wp.gp   gp<wp.gp    gp -q < wp.gp > results.txt &
wp.gp

Code:

is_weakly_prime(p) = {    my(s = digits(p), len = #s, original_digit, test_n);        \\ Iterate through each digit position    for(i = 1, len,        original_digit = s[i];                \\ Replace with every possible digit 0-9        for(d = 0, 9,            if(d == original_digit, next); \\ Skip the original digit            if(i == 1 && d == 0, next);    \\ Skip leading zeros                        \\ Construct the new number            s[i] = d;            test_n = fromdigits(s);                        \\ If any variation is prime, p is NOT weakly prime            if(isprime(test_n),                 s[i] = original_digit; \\ Reset before returning                return(0)            );        );        s[i] = original_digit; \\ Reset digit for next position    );    return(1);}get_weakly_primes(n) = {    my(primes_list = listcreate());    forprime(p = 2, n,        if(is_weakly_prime(p), listput(primes_list, p))    );    return(primes_list);}
gp -q < wp.gp > results.txt &
weekly+prfime_upto_ten million.jpg

Statistics: Posted by geev03 — Sat Feb 21, 2026 10:35 pm



Viewing all articles
Browse latest Browse all 7995

Trending Articles