g | x | w | all
Bytes Lang Time Link
157Rust240917T104954Zbzr
036Charcoal240918T005444ZNeil
011Japt240916T223015ZShaggy
059JavaScript ES6240916T201812ZArnauld
5625Vyxal gr240916T201441Zpacman25
130SageMath240917T105516ZSophia A
009Brachylog240917T093109ZFatalize
069Ruby240917T075106ZG B
00805AB1E240917T071811ZKevin Cr
097Python240916T201904ZTheLittl

Rust, 167 159 158 157 bytes

-1 byte thanks to ceilingcat

let g=|n|{if n==2{return 1}for i in 2..n{if n%i<1{return 0}}1};let f=|p:i32|{for q in 2..{if g(q)>0&&g(format!("{}{q}",p+q).parse().unwrap())>0{return q}}0};

Attempt This Online!

Charcoal, 36 bytes

Nθ≔³ηW⊙⟦ηI⁺I⁺ηθIη⟧⊙…¹÷견﹪κ⊕⊗μ≧⁺²ηIη

Try it online! Link is to verbose version of code. Explanation:

Nθ

Input p.

≔³η

Start with q=3.

W⊙⟦ηI⁺I⁺ηθIη⟧⊙…¹÷견﹪κ⊕⊗μ

Check that both p and (q+p)&q are prime by trial division of all odd numbers.

≧⁺²η

If not then add 2 to q and try again.

Iη

Output the found value of q.

The golfiest code I could find was to switch to Wilson's theorem for prime checking but this is even slower than odd divisor checking, however it does at least let me save a further byte (and cause even more slowdown) by checking all integers rather than odd ones:

Nθ≔³ηW⊙⟦ηI⁺I⁺ηθIη⟧﹪⊕Π…²κκ≦⊕ηIη

Try it online! Link is to verbose version of code. Only shows an input of p=11 as the given test case would take too much time to compute (even p=419 is too slow).

Japt, 13 11 bytes

@°s+X*j)j}a

Try it, run all test cases or check the first 1000 terms

@°s+X*j)j}a     :Implicit input of integer U
@               :Function taking an integer X as argument
 °              :  Postfix increment U
  s+            :  Convert to string and append
    X*          :    X multiplied by
      j         :      Is X prime?
       )        :  End string conversion and convert back to int
        j       :  Is result prime?
         }      :End function
          a     :Get the first integer >=0 that returns truthy

JavaScript (ES6), 59 bytes

p=>eval("for(d=q=1;q<d--|q%d&&n%d?1:d=n=d-1&&[++q+p]+q;)q")

Try it online!

faster / more readable, 61 bytes

p=>{for(d=q=1;q<d--|q%d&&n%d?1:d=n=d-1&&[++q+p]+q;);return q}

Try it online!

p => {              // p = input prime
  for(              // loop:
    d =             //   d = divisor
    q = 1;          //   q = the prime we're looking for
    q < d-- |       //   if q is less than d (decrement d afterwards)
    q % d           //   or d is not a divisor of q
    &&              //   AND
    n % d ?         //   q is not a divisor of n:
      1             //     keep searching
    :               //   else:
      d = n =       //     update d and n:
        d - 1       //       if d is not equal to 1 (meaning that
        &&          //       either q or n is composite):
        [++q + p] + //         increment q and build the new
        q;          //         candidate number
  );                // end of for()
  return q          // return q
}                   //

recursive, 55 bytes

p=>(g=d=>q<d--|q%d&&n%d?g(d):d-1?g(n=[++q+p]+q):q)(q=1)

Try it online!

Vyxal gr, 45 bitsv2, 5.625 bytes

Þp'⁰+Jæ

Try it Online!

Bitstring:

001010110100000101000111110000010010001101100
Þp'⁰+Jæ­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌⁢​‎⁠⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌­
Þp        # ‎⁡a list of infinite primes
  '       # ‎⁢filtered by
   ⁰+     # ‎⁣(p+q)
     J   # ‎⁤(p+q)"q
       æ  # ‎⁢⁡is prime
💎

Created with the help of Luminespire. Try it Online!

Bitstring:

00101011010000010100011111000101000101101101110110

7 bytes without vyncode, some filter magic.

-1 from r flag

SageMath, 130 bytes

def g(p): 
 for q in Primes(): 
  if is_prime(q+(p+q)*10^(1+int(log(q)/log(10)))):return q
print([g(p) for p in prime_range(100)])

Brachylog, 9 bytes

;.+;.cṗ∧ṗ

Try it online!

Explanation

;.+         Input + Output…
   ;.c      …concatenated with Output…
      ṗ     …is prime…
       ∧ṗ   …and Output itself is prime

Ruby, 69 bytes

->p{2.step.find{|q|(2...r="#{q+p}#{q}".to_i).all?{|x|r*q%x>0||x==q}}}

Try it online!

05AB1E, 8 bytes

∞Ø.Δ+y«p

Try it online or verify all test cases.

Explanation:

∞        # Push an infinite positive list: [1,2,3,...]
 Ø       # Map each to their 0-based n'th prime number: [3,5,7,...]
  .Δ     # Find the first prime in this list that's truthy for:
    +    #  Add it to the (implicit) input-integer
     y«  #  Append the current prime to this sum
       p #  Check if that is a prime itself
         # (after which the found result is output implicitly)

Although we skip prime 2 in the infinite list, since the infinite list starts at 1 and the n'th prime builtin is 0-based, it doesn't matter for the challenge, since appending a 2 to the sum will always result in an even number, and therefore never a prime.

Python, 97 bytes

g=lambda x:all(x%i for i in range(2,x))
f=lambda p,q=2:q if g(q)*g(int(f'{p+q}{q}'))else f(p,q+1)

Attempt This Online!