Skip to main content
Commonmark migration
Source Link

#MathGolf, 10 bytes

MathGolf, 10 bytes

∞╒g¶áÅ-±├Þ

Try it online.

Explanation:

∞            # Double the (implicit) input-integer
 ╒           # Create a list in the range [1, 2*n]
  g¶         # Filter so only the prime numbers remain
    áÅ       # Sort this list using the next two character:
      -±     #  The absolute difference with the (implicit) input-integer
        ├    # Push the first item of the list
             # (unfortunately without popping the list itself, so:)
         Þ   # Discard everything from the stack except for the top
             # (which is output implicitly as result)

#MathGolf, 10 bytes

∞╒g¶áÅ-±├Þ

Try it online.

Explanation:

∞            # Double the (implicit) input-integer
 ╒           # Create a list in the range [1, 2*n]
  g¶         # Filter so only the prime numbers remain
    áÅ       # Sort this list using the next two character:
      -±     #  The absolute difference with the (implicit) input-integer
        ├    # Push the first item of the list
             # (unfortunately without popping the list itself, so:)
         Þ   # Discard everything from the stack except for the top
             # (which is output implicitly as result)

MathGolf, 10 bytes

∞╒g¶áÅ-±├Þ

Try it online.

Explanation:

∞            # Double the (implicit) input-integer
 ╒           # Create a list in the range [1, 2*n]
  g¶         # Filter so only the prime numbers remain
    áÅ       # Sort this list using the next two character:
      -±     #  The absolute difference with the (implicit) input-integer
        ├    # Push the first item of the list
             # (unfortunately without popping the list itself, so:)
         Þ   # Discard everything from the stack except for the top
             # (which is output implicitly as result)
deleted 197 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#MathGolf, 10 bytes

∞╒g¶áÅ-±├ ±├Þ

(Note the trailing  / .)

Try it online (without the trailing  ), because it's currently giving an error..Try it online.

Explanation:

∞            # Double the (implicit) input-integer
 ╒           # Create a list in the range [1, 2*n]
  g¶         # Filter so only the prime numbers remain
    áÅ       # Sort this list using the next two character:
      -±     #  The absolute difference with the (implicit) input-integer
        ├    # GetPush the first item of the list
               # (unfortunately without popping the list itself, so:)
         Þ   # Discard everything from the stack except for the top
             # (which is output implicitly as result)

#MathGolf, 10 bytes

∞╒g¶áÅ-±├ 

(Note the trailing  / .)

Try it online (without the trailing  ), because it's currently giving an error..

Explanation:

∞            # Double the (implicit) input-integer
 ╒           # Create a list in the range [1, 2*n]
  g¶         # Filter so only the prime numbers remain
    áÅ       # Sort this list using the next two character:
      -±     #  The absolute difference with the (implicit) input-integer
        ├    # Get the first item of the list
              # Discard everything from the stack except for the top
             # (which is output implicitly as result)

#MathGolf, 10 bytes

∞╒g¶áÅ-±├Þ

Try it online.

Explanation:

∞            # Double the (implicit) input-integer
 ╒           # Create a list in the range [1, 2*n]
  g¶         # Filter so only the prime numbers remain
    áÅ       # Sort this list using the next two character:
      -±     #  The absolute difference with the (implicit) input-integer
        ├    # Push the first item of the list
             # (unfortunately without popping the list itself, so:)
         Þ   # Discard everything from the stack except for the top
             # (which is output implicitly as result)
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#MathGolf, 10 bytes

∞╒g¶áÅ-±├ 

(Note the trailing  / .)

Try it online (without the trailing  ), because it's currently giving an error..

Explanation:

∞            # Double the (implicit) input-integer
 ╒           # Create a list in the range [1, 2*n]
  g¶         # Filter so only the prime numbers remain
    áÅ       # Sort this list using the next two character:
      -±     #  The absolute difference with the (implicit) input-integer
        ├    # Get the first item of the list
             # Discard everything from the stack except for the top
             # (which is output implicitly as result)