Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: geev03 on February 22, 2026, 05:18:49 AM

Title: Delicate primes computed using PARI/GP (Tiny Core friendly)
Post by: geev03 on February 22, 2026, 05:18:49 AM
I’ve successfully computed delicate primes using PARI/GP, and wanted to share this here since it runs well even on minimal systems like Tiny Core Linux.

A delicate prime is a prime number such that changing any single decimal digit to any other digit always produces a composite number. Even one digit mutation destroying primality makes these primes extremely rare and interesting.

PARI/GP approach

The idea is simple and efficient:

Check if a number is prime

For each digit position:

Replace the digit with all other digits 0–9

Skip the original digit

Test primality of the modified number

If any modification is prime → reject

If all modifications are composite → delicate prime
Code: [Select]

isdelicate(p)=
{
  if (!isprime(p), return(0));
  d = digits(p);
  for (i=1, #d,
    for (x=0,9,
      if (x != d[i],
        v = fromdigits(subst(d, i, x));
        if (v > 1 && isprime(v), return(0))
      )
    )
  );
  return(1);
}

delicates(limit)=
{
  forprime(p=2, limit,
    if (isdelicate(p),
      print(p)
    )
  )
}

Usage example:

delicates(10^7)
Notes

Runs comfortably on low-memory systems

No external libraries needed beyond PARI/GP

Easy to adapt for:

Larger ranges

Other bases

“Strong” delicate prime definitions

This is another nice example of how PARI/GP shines on minimal Linux setups like Tiny Core when exploring number theory.

To get the result in a file, gp -q <wp.gp > result.txt &