Skip to main content
Commonmark migration
Source Link

Brachylog, 7 5 bytes

;I≜-ṗ

Try it online!

Saved 2 bytes thanks to @DLosc.

###Explanation

Explanation

;I≜      Label an unknown integer I (tries 0, then 1, then -1, then 2, etc.)
   -     Subtract I from the input
    ṗ    The result must be prime

Brachylog, 7 5 bytes

;I≜-ṗ

Try it online!

Saved 2 bytes thanks to @DLosc.

###Explanation

;I≜      Label an unknown integer I (tries 0, then 1, then -1, then 2, etc.)
   -     Subtract I from the input
    ṗ    The result must be prime

Brachylog, 7 5 bytes

;I≜-ṗ

Try it online!

Saved 2 bytes thanks to @DLosc.

Explanation

;I≜      Label an unknown integer I (tries 0, then 1, then -1, then 2, etc.)
   -     Subtract I from the input
    ṗ    The result must be prime
deleted 227 characters in body
Source Link
Fatalize
  • 39.3k
  • 5
  • 70
  • 162

Brachylog, 77 5 bytes

∧≜ṅ;?+ṗ;I≜-ṗ

Try it online!Try it online!

Saved 2 bytes thanks to @DLosc.

###Explanation

∧≜   ;I≜      Label an unknown integer I (tries 0, then 1, then -1, then 2, etc.)
 Negate
  - ;?+    Subtract AddI tofrom the input
      ṗ    The result must be prime

We label a free integer which will attempt values in the order 0, 1, -1, 2, -2, 3, etc. We then negate this number so that -1 is tried before 1, -2 before 2 etc., to respect the tiebreaker that the smaller of the 2 primes must be outputted.

Brachylog, 7 bytes

∧≜ṅ;?+ṗ

Try it online!

###Explanation

∧≜         Label an unknown integer (tries 0, then 1, then -1, then 2, etc.)
 Negate
   ;?+     Add to the input
      ṗ    The result must be prime

We label a free integer which will attempt values in the order 0, 1, -1, 2, -2, 3, etc. We then negate this number so that -1 is tried before 1, -2 before 2 etc., to respect the tiebreaker that the smaller of the 2 primes must be outputted.

Brachylog, 7 5 bytes

;I≜-ṗ

Try it online!

Saved 2 bytes thanks to @DLosc.

###Explanation

;I≜      Label an unknown integer I (tries 0, then 1, then -1, then 2, etc.)
   -     Subtract I from the input
    ṗ    The result must be prime
Source Link
Fatalize
  • 39.3k
  • 5
  • 70
  • 162

Brachylog, 7 bytes

∧≜ṅ;?+ṗ

Try it online!

###Explanation

∧≜         Label an unknown integer (tries 0, then 1, then -1, then 2, etc.)
  ṅ        Negate
   ;?+     Add to the input
      ṗ    The result must be prime

We label a free integer which will attempt values in the order 0, 1, -1, 2, -2, 3, etc. We then negate this number so that -1 is tried before 1, -2 before 2 etc., to respect the tiebreaker that the smaller of the 2 primes must be outputted.