1, 2, 3, 14... or is it 15?

Jelly, 16 + 16 + 1² = 33

A107083

⁵*+31ÆḍÆNB>/
1Ç#

Try it online!

A221860

⁵*+31ÆạÆNB>/
1Ç#

Try it online!

How it works

1Ç#           Main link. Argument: n

1             Set the return value to 1.
 Ç#           Call the helper link with arguments k, k + 1, k + 2, ... until n of
              them return a truthy value. Return the array of n matches.


⁵*+31ÆḍÆNB>/  Helper link. Argument: k

⁵*            Yield 10**k.
  +31         Yield 10**k + 31.
     Æḍ       Count the proper divisors of 10**k + 31.
              This yields c = 1 if 10**k + 31 is prime, an integer c > 1 otherwise.
       ÆN     Yield the c-th prime.
              This yields q = 2 if 10**k + 31 is prime, a prime q > 2 otherwise.
         B    Binary; yield the array of q's digits in base 2.
          >/  Reduce by "greater than".
              This yields 1 if and only if the binary digits match the regex /10*/,
              i.e., iff q is a power of 2, i.e., iff 10**k + 31 is prime.


⁵*+31ÆạÆNB>/  Helper link. Argument: k

     Æ        Unrecognized token.
              The token, as well as all links to its left, are ignored.
       ÆN     Yield p, the k-th prime.
      ạ       Take the absolute difference of k and p, i.e., p - k.
         B    Binary; yield the array of (p - k)'s digits in base 2.
          >/  Reduce by "greater than".
              This yields 1 if and only if the binary digits match the regex /10*/,
              i.e., iff p - k is a power of 2.

Pyth, 9 + 11 + 9² = 101 bytes

1, 2, 3, 14

.fP_+31^T

Try it online!

1, 2, 3, 15

.fsIl-e.fP_

Try it online!


Jelly, 12 + 12 + 8² = 88 bytes

1, 2, 3, 14

ÆN_µæḟ2=
1Ç#

Try it online!

1, 2, 3, 15

10*+31ÆP
1Ç#

Try it online!