# Tag Info

2

APL, 9 chars/bytes 2≡≢∪∨∘⍳⍨⎕ get the input ⎕ compute least common divisor between n and all integers from 1 to n ∨∘⍳⍨ count of unique values ≢∪ if it's exactly 2, then it's prime 2≡

0

Symbolic Raku, 17 bytes $_=?($_%%[^] ^$_) Try it online! Suprisingly, this is shorter than the my previous Raku answer, though one byte longer than using the built-in Explanation:$_= # Set the output to ?( ) # The boolean of \$_ # If the input is %% # Divisible by [^] # Only one ...

0

tq, 10 bytes ?-1!xp*p%? Explanation Uses Wilson's theorem to do the prime-checking. ?-1! # Generate all numbers from 2 to input - 1 x, # Preserve this value, prevent it from being printed p*p # Generate all possible combinations of those numbers %? # Does the product of any combination equal to the input?

0

Spice, 93 bytes ;i;m;t;c;r@REA i;ADD 0 1 c;SUB i 1 m;ADD c 1 c;MOD i c t;SWI t 1 9;SWI c m 3;ADD 0 1 r;OUT r; This outputs [1] for a prime, and [] for a non-prime. Un-golfed explanation: ;i;m;t;c;r@ - Declare vars (@ marks end of declarations) (line 0) REA i; - Read input into i (line 1) ADD 0 1 c; - Set counter c = 1 (line 2) SUB i 1 m; - Set ...

1

W d, 5 bytes (Possibly the only <=5-byter that does not use a prime or number factorization built-in?) ⊂ℝ]Aא Unpacked: m!Wk2= And, just for the lols (explanation for this program is also below, without the implicitly provided ba): W d, 13 7 bytes W doesn't have a boring primalty test operation, which is why this program is so long. (IMO a 7-byte ...

0

Wren, 48 43 bytes I feel surprised that I think better when using W instead of Wren. Also, the 1-primalty problem is fixed. Fn.new{|i|(1..i).where{|x|i%x==0}.count==2} Try it online!

Top 50 recent answers are included