2 deleted 53 characters in body
source | link

Gaia, 53 bytes

ṅ@D∫(ṅD⌡

Try it online!Try it online!

VeryRather slow for large inputs, but works given enough memory/time. Note that

I'm not sure why D⌡ sorts its result by utilizing python'simplicitly pushes sorted()z, which should guarantee a stable sort again, so in event ofbut it makes this a tie, the least prime is returned.remarkably short answer!

ṅ	| implicit input z: push first z prime numbers, call it P
 @	| push z again
 D⌡	| D∫	|take Takethe absolute difference, elementwise, and sortbetween P intoand ascending(implicit) orderz,
	| byreturning result
the smallest value in (	|P Takewith firstthe elementminimum ofabsolute Pdifference

Gaia, 5 bytes

ṅ@D∫(

Try it online!

Very slow for large inputs, but works given enough memory. Note that sorts its result by utilizing python's sorted(), which should guarantee a stable sort, so in event of a tie, the least prime is returned.

ṅ	| implicit input z: push first z prime numbers, call it P
 @	| push z again
  D∫	| Take absolute difference, elementwise, and sort P into ascending order by result
    (	| Take first element of P

Gaia, 3 bytes

ṅD⌡

Try it online!

Rather slow for large inputs, but works given enough memory/time.

I'm not sure why D⌡ implicitly pushes z again, but it makes this a remarkably short answer!

ṅ	| implicit input z: push first z prime numbers, call it P
 D⌡	| take the absolute difference between P and (implicit) z,
	| returning the smallest value in P with the minimum absolute difference
1
source | link

Gaia, 5 bytes

ṅ@D∫(

Try it online!

Very slow for large inputs, but works given enough memory. Note that sorts its result by utilizing python's sorted(), which should guarantee a stable sort, so in event of a tie, the least prime is returned.

ṅ	| implicit input z: push first z prime numbers, call it P
 @	| push z again
  D∫	| Take absolute difference, elementwise, and sort P into ascending order by result
    (	| Take first element of P