APL (Dyalog Classic), (削除) 33 (削除ここまで) 31(削除) 31 (削除ここまで) 26 bytes
{⍵∊∊(((×ばつ⍨)1↓⍳)⍵)∘* ̈⍳⌈⍵*0.5∘* ̈⍳⍵}
-5 bytes from Kevin Cruijssen's suggestion.
Warning: Very, very slow for larger numbers.
Explanation
{⍵∊∊(((×ばつ⍨)1↓⍳)⍵)∘* ̈⍳⌈⍵*0.5∘* ̈⍳⍵} ⍵=n in all the following steps
⍳⌈⍵*0.5⍳⍵ range offrom 1 to ceil of sqrt(n)
∘* ̈ distribute power operator across left and right args
(((×ばつ⍨)1↓⍳)⍵) list of primes till n
∊ flatten the right arg(monadic ∊)
⍵∊ is n present in the primes^(1..n)?
APL (Dyalog Classic), (削除) 33 (削除ここまで) 31 bytes
{⍵∊∊(((×ばつ⍨)1↓⍳)⍵)∘* ̈⍳⌈⍵*0.5}
Explanation
{⍵∊∊(((×ばつ⍨)1↓⍳)⍵)∘* ̈⍳⌈⍵*0.5} ⍵=n in all the following steps
⍳⌈⍵*0.5 range of 1 to ceil of sqrt(n)
∘* ̈ distribute power operator across left and right args
(((×ばつ⍨)1↓⍳)⍵) list of primes till n
∊ flatten the right arg(monadic ∊)
⍵∊ is n present in the primes^(1..n)?
APL (Dyalog Classic), (削除) 33 (削除ここまで) (削除) 31 (削除ここまで) 26 bytes
{⍵∊∊(((×ばつ⍨)1↓⍳)⍵)∘* ̈⍳⍵}
-5 bytes from Kevin Cruijssen's suggestion.
Warning: Very, very slow for larger numbers.
Explanation
{⍵∊∊(((×ばつ⍨)1↓⍳)⍵)∘* ̈⍳⍵} ⍵=n in all the following steps
⍳⍵ range from 1 to n
∘* ̈ distribute power operator across left and right args
(((×ばつ⍨)1↓⍳)⍵) list of primes till n
∊ flatten the right arg(monadic ∊)
⍵∊ is n present in the primes^(1..n)?
APL (Dyalog Classic), (削除) 33 (削除ここまで) 31 bytes
{⍵∊∊(((×ばつ⍨)1↓⍳)⍵)∘* ̈⍳⌈⍵*0.5}
Explanation
{⍵∊∊(((×ばつ⍨)1↓⍳)⍵)∘* ̈⍳⌈⍵*0.5} ⍵=n in all the following steps
⍳⌈⍵*0.5 range of 1 to ceil of sqrt(n)
∘* ̈ distribute power operator across left and right args
(((×ばつ⍨)1↓⍳)⍵) list of primes till n
∊ flatten the right arg(monadic ∊)
⍵∊ is n present in the primes^(1..n)?