g | x | w | all
Bytes Lang Time Link
016APLNARS250616T174651ZRosario
043GNU sed E + coreutils250613T134813ZToby Spe
059Bash or any Bourne shell + coreutils + grep250520T172831ZDavid G.
054JavaScript Node.js250519T063752Zl4m2
004Brachylog250610T125246ZFatalize
122Python 3250521T081344ZStef
011Husk250524T102004ZGlory2Uk
105Racket250520T070123ZGalen Iv
022Wolfram Language Mathematica250519T073705Zatt
019J250520T075657ZGalen Iv
042Maple250520T005618Zdharr
007Vyxal 3 l250519T045836Zlyxal
040Ruby250519T145646ZJordan
00605AB1E legacy250519T132324ZNeil
025Charcoal250519T132010ZNeil
042Retina 0.8.2250519T074509ZNeil
009Uiua 0.17.0dev.1250519T050515ZTbw

APL(NARS), 16 chars

{(4=≢m)∧m≡∪m←π⍵}

Here 1 means true, 0 means false. It would say "the list of factors are of different elements, and them have to be 4 elements only", test:

  {(4=≢m)∧m≡∪m←π⍵}1974
1
  {(4=≢m)∧m≡∪m←π⍵}1975
0

GNU sed -E + coreutils, 48 43 bytes

Outputs the number and its factors for truthy; no output for falsey. It requires a recent version of factor with the -h option to "print repeated factors in form p^e unless e is 1" (TIO does not have a new enough version).

s/.*/factor -h &/e
/\^/d
/^(\S* ){4}\S*$/!d

First line does the factoring. Second line checks for repeated factors. Third line checks for exactly four spaces in the line.

Bash (or any Bourne shell) + coreutils + grep, 59 bytes

t(){ factor $1|egrep ':( [^ ]*){4}$'|egrep -v '( .*)\1\>';}

Try it online!

The function outputs the number and its factors like: 210: 2 3 5 7 for truthy, and empty for falsy. It also returns a standard shell truth value.

My test driver (see TIO) outputs the input, runs the function, and then outputs either "truthy" or "falsy" for good measure.

Some added recommended truthy tests: 1000000000254000000023512000000939666000013638807 (a 160 bit number, to overflow any native int), 1590 (2 * 3 * 5 * 53, tests that finding " 5 5" and making it falsy is wrong.)

JavaScript (Node.js), 54 bytes

f=(n,i=4,p=2)=>n<2?!i:n%p?f(n,i,p+1):n/p%p&&f(n/p,i-1)

Try it online!

Brachylog, 4 bytes

ḋ≠l4

Try it online!

Explanation

Another situation where having a built-in for "all-different" (which is useful for constraint/logic based programming in general) is valuable.

ḋ        The prime decomposition of the input…
 ≠       …is a list of all distinct numbers…
  l4     …and its length is 4

Python 3, 122 bytes

lambda x:len(l:=[p for p in f(x)if not f(p)])==4and x==math.prod(l)
f=lambda x:[p for p in range(2,x)if x%p<1]
import math

Try it online!

Shaved 5 bytes thanks to Rhaixer: lambda instead of def and <1 instead of ==0

Husk, 11 bytes

=+4§-LoΠup¹

If the input number is a product of 4 unique primes, output is 1, otherwise 0. Removing the first and the last symbols (9 bytes) will change the output either to the input value (truthy, except for 0) or to something else (falsy).

Try it online!

Commented

        up  -- get the unique prime factors
      oΠ    -- calculate the product
     L  up  -- calculate the length = number of the unique factors
   §-       -- substract the length from the product
 +4         -- add 4
=         ¹ -- is the output the same as the input?

Husk, 7 bytes

€mΠṖ4İp

If the result is truthy - outputs a whole number, otherwise the program will loop infinitely.

Try it online!

Commented

     İp  -- generate a list of primes
   Ṗ4    -- make a list of 4 element permutations
 mΠ      -- calculate the products
€        -- check whether the input number belong to the output list

Racket, 105 bytes

(require math/number-theory)(define(f n)(let((q(prime-divisors n)))(and(= 4(length q))(= n(apply * q)))))

Try it online!

Wolfram Language (Mathematica), 24 22 bytes

-2 thanks to LegionMammal278

8#2&@@√#==PrimeNu@#&

Try it online!

Returns an indefinite (falsy) form 0 == PrimeNu[0] when given 0. Use === (+1 byte) instead for False.

        ==PrimeNu@# #distinct prime factors equals...
8#2&@@√#             (input = a*b^2, b maximal)
                      a=1: input
                      b=1: 8*1/2
                      else 8*√a

J, 22 19 bytes

1(=4*/@{.~.@q:)@>.]

Try it online!

1(=4*/@{.~.@q:)@>.]
1               >.]   NB. max of 1 and the argument
 (            )@      NB. do (the inside is a hook)
         ~.@q:        NB. unique prime factors 
   4   {.             NB. take the first 4 factorsfactors row
                      NB. (padded with zeroes if needed)
    */@               NB. and find their product
  =                   NB. is it equal to the argument of the hook?

Maple, 42 bytes

n->evalb(map2(op,2,ifactors(n)[2])=[1$4]);

Vyxal 3 -l, 7 (literate) bytes

prime-exponents 
1 4 list-repeat 
===

Vyxal It Online!

1 4 list-repeat is a 3 byte way of writing [1, 1, 1, 1]

Ruby, 40 bytes

Port of Neil’s 05AB1E solution; give him an upvote.

->n{n>0&&n.prime_division.sum{_2**3}==4}

Attempt This Online!

05AB1E (legacy), 6 bytes

Ó3mO4Q

Try it online! Explanation: Checks that the sum of the cubes of the prime exponents equals 4.

Charcoal, 25 bytes

Nθ≔Φ…²θ¬﹪θιυ∧⁼¹⁴Lυ⁼υ⁻υXυ²

Try it online! Link is to verbose version of code. Explanation:

Nθ

Input n.

≔Φ…²θ¬﹪θιυ

Find the nontrivial proper factors of n.

∧⁼¹⁴Lυ⁼υ⁻υXυ²

Check that there are 14 and none of them are square numbers.

Retina 0.8.2, 42 bytes

.+
$*_
(.+)(\1)*(?=\1$)
$#2¶
D`
^(.+¶){4}_

Try it online! Link includes smaller test cases. Explanation:

.+
$*_

Convert to unary using _s.

(.+)(\1)*(?=\1$)
$#2¶

Decompose into prime factors (except subtract 2 from each factor), leaving a trailing _.

D`

Replace duplicate prime factors with empty lines.

^(.+¶){4}_

Check that there are exactly four non-empty lines before the _.

Uiua 0.17.0-dev.1, 9 bytes SBCS

≍⇡4⊛°/×↥1

Try on Uiua Pad!

Takes input on stack and outputs 1 for true and 0 for false.

Explanation

≍⇡4⊛°/×↥1
↥1        # round up to 1
°/×       # prime factorization
⊛         # unique index for each unique factor
≍⇡4       # is it == range(4)?