[Question]
  [
Surprisingly, I don't think we have a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") question for determining if a number is [semiprime](https://en.wikipedia.org/wiki/Semiprime). 
> 
> A semiprime is a natural number that is the product of two (not necessarily distinct) prime numbers. 
> 
> 
> 
Simple enough, but a remarkably important concept.
Given a positive integer, determine if it is a semiprime. Your output can be in any form so long as it gives the same output for any truthy or falsey value. You may also assume your input is reasonably small enough that performance or overflow aren't an issue. 
Test cases:
```
input -> output
1     -> false
2     -> false
3     -> false
4     -> true
6     -> true
8     -> false
30    -> false   (5 * 3 * 2), note it must be EXACTLY 2 (non-distinct) primes
49    -> true    (7 * 7)      still technically 2 primes
95    -> true
25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784406918290641249515082189298559149176184502808489120072844992687392807287776735971418347270261896375014971824691165077613379859095700097330459748808428401797429100642458691817195118746121515172654632282216869987549182422433637259085141865462043576798423387184774447920739934236584823824281198163815010674810451660377306056201619676256133844143603833904414952634432190114657544454178424020924616515723350778707749817125772467962926386356373289912154831438167899885040445364023527381951378636564391212010397122822120720357
      -> true, and go call someone, you just cracked RSA-2048
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so standard rules apply! 
  
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 2 [bytes](https://github.com/JCumin/Brachylog/wiki/Code-page)
Basically a port from [Fatalize's answer](https://codegolf.stackexchange.com/a/135298/53748) to the Sphenic number challenge.
```
·∏ãƒä
```
**[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//@GO7iNd//@bWP4HAA "Brachylog ‚Äì Try It Online")**
### How?
```
·∏ãƒä - implicitly takes input
·∏ã  - prime factorisation (with duplicates included)
 ƒä - is a couple
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 [bytes](https://github.com/barbuz/Husk/wiki/Codepage)
Look ma no Unicode!
```
=2Lp
```
**[Try it online!](https://tio.run/##yygtzv7/39bIp@D///8mlgA "Husk ‚Äì Try It Online")**
### How?
```
=2Lp - a one input function
   p - prime factorisation (with duplicates included)
  L  - length
=2   - equals 2?
```
[Answer]
# [Pyth](https://pyth.readthedocs.io), 4 bytes
```
q2lP
```
**[Test suite](http://pyth.herokuapp.com/?code=q2lP&input=36&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A6%0A30%0A49%0A95&debug=0).**
---
# How?
```
q2lPQ     - Q is implicit input.
q2        - Is equal to 2?
    lPQ   - The length of the prime factors of the input.
```
[Answer]
# Mathematica, 16 bytes
```
PrimeOmega@#==2&
```
`PrimeOmega` counts the number of prime factors, counting multiplicity.
[Answer]
# [Python 3](https://docs.python.org/3/), 54 bytes
```
lambda n:0<sum((n%x<1)+(x**3==n)for x in range(2,n))<3
```
[Try it online!](https://tio.run/##FctBCsIwEAXQq8xGmNS/aJJWbElOoi4iGi3YaYkV4ulj3D5463d7LmJL9OfyCvP1FkjG1r0/M7PsstNqz7lprPei4pIo0ySUgjzubCBKuVory59PGgYWHQ44wrboBgw9tOkv45om2YgFkWsqPw "Python 3 ‚Äì Try It Online")
The [previous verson](https://tio.run/##FcvRCoIwFAbgV9mNcCY/5Nm0UmYvUl0saiXkUZaBPv1atx9887a8JrEp9Jf09uPt7pV0UpbEO6sLPlXu8x1JitVxmKJa1SAqenk@yEC0dnlmlj@fGQYWNfY4wlaoW7QN2DTXbo6DLIoEgXJKhx8) had some rounding issues on large cube numbers (`125`,`343`,etc)  
This calculates the amount of divisors (not only primes), if it has `1` or `2` it returns `True`.  
The only exception is when a number has more than two prime factors but only two divisors. In this case it is a perfect cube of a prime (its divisors are its cube root and its cube root squared). `x**3==n` will cover this case, adding one to the cube root entry pushes the sum up to a count of 3 and stops the false-positive.
thanks Jonathan Allan for writing with this beautiful explanation
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~56~~ 48 bytes
```
->x{r=c=2;0while x%r<1?(x/=r;c-=1):x>=r+=1;c==0}
```
[Try it online!](https://tio.run/##BcHRCkAwFAbgV9mNIoyp3Zh/HkQuWBZF6ZQcsWef76NrfqJHLC2/BIfG1Pe67YvghDrVp1yBjCuhspYtKIcyDqhDTJWUWmfymM734@8UAxfCDzyOIf4 "Ruby ‚Äì Try It Online")
### How it works:
```
->x{                    # Lambda function
    r=c=2;              # Starting from r=2, c=2
    0 while             # Repeat (0 counts as a nop)
        x%r<1? (        # If x mod r == 0
            x/=r:       # Divide x by r
            c-=1        # decrease c
        ):              # else
            x>=r+=1     # increase r, terminate if r>x 
    );
    c==0                # True if we found 2 factors
}
```
Thanks Value Ink for the idea that saved 8 bytes.
[Answer]
# Mathematica, ~~31~~ 29 bytes
```
Tr[Last/@FactorInteger@#]==2&
```
[Answer]
# [Neim](https://github.com/okx-code/Neim), 4 bytes
```
ùêèùê•Œ¥ùîº
```
[Try it online!](https://tio.run/##y0vNzP3//8PcCf1AvPTclg9zp@z5/9/SFAA "Neim ‚Äì Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 67 bytes
```
lambda k:f(k)==2
f=lambda n,k=2:n/k and(f(n,k+1),1+f(n/k,k))[n%k<1]
```
[Try it online!](https://tio.run/##LcjLDoIwEEbhvU8xG5M2/Am24IXGeRJkUUOKZHQghAU@fWXh7nxn/q6vSX0e@JHf8fPsI0lIRiyzPyT@L4WwD1oKRe1NMrsLZ@GKPUuBWNvqUe6uy2laaKNRqXXwqFDjghuqE@oGzbkL8zLqSoPZbL7@AA "Python 2 ‚Äì Try It Online")
***-10 bytes thanks to @JonathanAllan!***
Credit for the Prime factorization algorithm goes to [Dennis](https://codegolf.stackexchange.com/a/104591) (in the initial version)
[Answer]
## JavaScript (ES6), 47 bytes
Returns a boolean.
```
n=>(k=1)==(d=n=>++k<n?n%k?d(n):d(n/k--)+1:0)(n)
```
### Demo
```
let f =
n=>(k=1)==(d=n=>++k<n?n%k?d(n):d(n/k--)+1:0)(n)
console.log(
  [...Array(200).keys()].filter(f).join`, `
)
```
[Answer]
# Mathematica 32 bytes
Thanks to ngenesis for 1 byte saved
```
Tr@FactorInteger[#][[;;,2]]==2&
```
[Answer]
# [J-uby](https://github.com/cyoce/J-uby) + `prime`, 34 bytes
```
:prime_division|:*&:pop|:sum|:==&2
```
[Try it online!](https://tio.run/##HcbRCoMgFADQ9/sVUlAw7qLSIoW@JCK2ZcxB6jIHI/t2BztP53X192/c5NurTZLcbmqVOcDSR/H/NKuPcsroIC6ZsMYG4fwaRN9ndRwqrJEiwxY7pCUyjrwZC3l7PMlsSNABCLF@dyRJD30Kkh7LoIvdTGo8E5B6jhXUQIFBCx3QEhgH3vwA "J-uby ‚Äì Try It Online")
[Answer]
# Regex (ECMAScript or better), ~~24~~ 23 bytes
```
(?=((x(x*))\2+)\1+$)\3^
```
*-1 byte [thanks to Grimmy](https://chat.stackexchange.com/transcript/message/50001768#50001768)*
[Try it online!](https://tio.run/##Tc89b8IwFIXhv0KjCu4lTUgo6oBrmDqwMLRjaSUrXJzbGseyDaR8/PYUhkqdnyMdvV9qr0Ll2cUsOF6T3zb2m346Ly0deq@kX1oHcJSz0bCDuQRooR0irsYprsr0HlePn91wdMQ8Nm/Rs9WAeTBcETw9ZBNEEWQhDjUbAjDSk1obtgSId9LujMGTliYPznCEQTZAwRsAK3VuyOpY42x8PnNYqiWwdMoHWtgI@r34QPwD@g92Vs7L6Y0x1r45JAu7V4bXPa@spmkvSY3YNB4EP0sSnKZ4PUzaJPfkSEVgzLcqVjV4xFPo9901KcKtohRuF0P014m4XLoimxTFLw "JavaScript (SpiderMonkey) ‚Äì Try It Online") - ECMAScript  
[Try it online!](https://tio.run/##NY7NasMwEAbvfopF5LAb/yAlOdkRfRDbhdAqjYq6MiuVOk/vRim9Ld8wwy73fIt83PzXEiVDuqdGXPOZIg8gVpRSG75YxBXXPdF0qGky9Y6m4@v2YKPpWzMP4K2urlEggOfS6FJ@99xXEGzo0hJ8RtUqqsBfITjGQOdDD2E0sw2jnisoMhdZLvzh0HPGAqj5u8xMtaFHrwTEdcld5O2G0oBa1Z6fpCDfwyJFoedgzfD/TfzO3Y/47DBlQSbadHvS@hc "Python 3 ‚Äì Try It Online") - Python  
[Try it online!](https://tio.run/##PY5Bb8IwDIXv@xVeNYkEVivtdiJEqIIK7cIktlvLok2EEikKVRpEd9lf7xLYONiSn9/3bHf6@h4cCNioRvUtWnWGZfFeoFOfu8erOJ2@rNavm3JRvJUctGAczgdtFBjRKN/dAeg9mCrNtkIktU14WJiKIab5loOyu@AICnat0Z6M0hH9Q9Ao2/gDobM8MFXgA3ZD9kcHFrSFKKI/Sk0yRhGj8TYG3yWLJH0ythTEDzgeBX0f/2xPvrvkxb@zMDttPdj/E7HHkrJcL6UcyFwQ0pN@TGmdT2idTR5o/fQxDCx9ZuwX "Ruby ‚Äì Try It Online") - Ruby
Takes its input in unary, as a string of `x` characters whose length represents the number.
This regex is based on the 18 byte "Is it prime?" regex `(?=(x(x*))\1+$)\2^`, which unlike its semiprime version above, is longer than the shortest known, the 16 byte `^(?!(xx+)\1+$)xx`. But like `^(?=(xx+?)\1*$)\1$` (also 18 bytes), it has the interesting attribute of implicitly rejecting 0 and 1 as prime numbers, whereas the 16 byte regex must explicitly reject them (the `xx` at the end).
```
                  # tail = N = input number; there's no need to anchor here,
                  # because a start anchor is used at the end of this regex
(?=
    (             # \1 = largest proper divisor of N that is >=2
        (x(x*))   # \2 = largest proper divisor of \1; \3 = \2 - 1
        \2+       # Assert that \2 is a proper divisor of \1
    )
    \1+$          # Assert that \1 is a proper divisor of N
)
\3^               # Assert that \3==0, and thus \2==1, meaning the largest proper
                  # divisor of the largest proper divisor of N is 1, meaning N is
                  # semiprime
```
# Regex (Perl / Java / PCRE / Python[`regex`](https://bitbucket.org/mrabarnett/mrab-regex/src/hg/) / .NET), 23 bytes
```
^(?>((x(x*))\2+)\1+$)\3
```
[Try it online!](https://tio.run/##RY5fa8IwFMW/ykWCzV1bmjh8MU2t4F592tvqghMLgUy7pEIlZF@9xk7Yy@Wec/@cX3eyZjl@34BYAd5cjgcDpBBRynK7ed9UAdqLpcRJJspKoAfdRoW@s/rcw6w5z0SA2kjXGd3TJE8yd/1yfTxRWc4zjqefx9L632XRxxVRKB6/XEw82NqUC/S1@eB7GSvbi2eufkqiSzmNY5em6HULlCZDAgPEJUSQv1AQW6Anbj6f4Ca2CM7FHyvRIoSg1Ntuq9T4SdcVpQMdXhCbRYoNTwk2r@PI8iVjdw "Perl 5 ‚Äì Try It Online") - Perl  
[Try it online!](https://tio.run/##bVLvb9MwEP2@v@KIQLXbzkuH@IIXJkAgITFA28e2SG7itO6cS7CdNdu0v72c0/BjUvPlcnfP7/yeb6vu1Om2uN2bqqldgC3lwtRiLOH/ShuMPVpzeq076pw07cqaHHKrvIcrZRAeYaj5oAKFu9oUUFGH3QRncA3Krf18ySFsXL3z8KnLdRNMTSdPAD4bq6HMUO/6X5aIvC60oH7C5Ye2LLXTxbVWhXaw6mHPi@zPySEtOZfDXD8NcreJ/Iz5bEUaVPHVoGacv8iwtZabknmhf7XKepacjcfjhPPH59ADA2PhKMEjMYS/DERwRgwrwt1KP8lGCxzFGOTTofb0Q4WgHYLLhj9SWzVxgOeS3FjVtdUK4SEriVFLuMkVIkk32LQBMohqhxq7ufdBV8IglzDo7GFio/w33QW6Zm8xwGCIpbsTxwGEhBgkDv35Eiy1I0r4xprAklN6BMIHwJQ6XzDQGjjRKOc1JczO0yWfAs6ONoXVuA6bi3O4hIiEtxRmS2LMN8rNl92gp89wtpTw3jl170VprGXddNSNelMAytpFbXSNDFMJeJHhjMJkQgKvVMg35FBFbE5Uh4z1m4u04B@J/LAxYudUw4YRed3cfy@vFa41TUqnyHlUWgKraDwW5F182wc@mFyTYztngmbxUbl8yIJr4/v8azfkYShZ8sonZAmXT/E7iVu1/8ku3zHWsW7M@eJ8whezyUu@eL2PC7NPT9@k6W8 "Java (JDK) ‚Äì Try It Online") - Java  
[Try it online!](https://tio.run/##XVBda4MwFH3vrwghYG7VVl27UVLXl21QGHvY9la7YF2sMhtDTEEo/e3uWva0h1zu1znn5pjKDOuNqQxhlqSEzimZEWPVUVplmrxQ3JvPphspq7xxsmhPpm6UzXgGInufd15APHwlNuVRjQvaKe06LuXL9vVZSghIDEiJxGJS61p2ynFqCqtmh7z4cRaDbOpT7WhA6CJZLVb3D8lqSUFMytZyVqeRYE1aInvHPz6ftm8g4ELqkrNm1znbKI0ZhPE@TWmmKeBydz7gBNtBFIQxjHjVm6b9VpyGNMB1gfiiPWs3YtcJgnZIgDHaiwkhN2X9VzO9Tm9zzHwfUJrwm0On3BUVZzZAsdEulTvu9V7ANACQy3hiDaqo2vEuQfArsSBjTZgWV5S5/rOVgxi@@OaR8573U4As8SGLfQbZ3TBE4TKKfgE "PHP ‚Äì Try It Online") - PCRE  
[Try it online!](https://tio.run/##NY7NasMwEAbvfopF5LAb/yAl5GLH7YPYLoRWSVTUlVmp1Hl6N3Lpbdlhhm9@pHvg4@q@5iAJ4iNWYm92qT5j4A6kF6XU@oavL4gLLnui8VDSaModjcf1yQbT1mbqwPW6uAYBD45zponpw3FbgO99E2fvEqpaUQHuCt4yejofWvCDmXo/6KmALHOW5cI3i44TZkDV32UmKg09ezmwTWyivcj7HaUCtag9bzBT18Is2aLt0Zvuf1D4Ts2PuGQxJkEmWnV90voX "Python 3 ‚Äì Try It Online") - Python `import regex`  
[Try it online!](https://tio.run/##RY/RaoQwFER/ReSCyaZZ4pa@bEi70Od@gVoQe7cG0huJWZSVfLvVltLHMwyHmcFPGMYenVshmCrgJ87N@Uw4sUuxvrOXZ8ZmNh84r0@C16UAXj@uxeUhf/Vfg3X4kXMNd6P01Qdsu56ByyxlYGm4Rb5Aa8DJcXA25jLX9sqgPXb@RlG6mJ32gjDQVqpJm4ABmcpSbH4SDSQd/nG5sxB82R3h@NbGrseRFXNxAOK/8Z0vU7ARZe/HmLZZpf7nTJLffjlLmAGllFYln5T6Bg "PowerShell ‚Äì Try It Online") - .NET
This is a direct port of the "ECMAScript or better" regex above, using an atomic group instead of an atomic lookahead. It is much faster on most regex engines, as the `^` start-anchor test is done first instead of last.
# Regex (Perl / Java / PCRE / Python[`regex`](https://bitbucket.org/mrabarnett/mrab-regex/src/hg/)), 23 bytes
```
^((x+)\2*(?=\2$)){2}+x$
```
[Try it online!](https://tio.run/##RY7NasMwEIRfZQlLrK1tLBtyqazEgfTaU291ItISg0BJHMkFF6G@uqu4gV6Wndmf@fqTNavp/A1oBXhz/TwawEJEKevd9m27DtBdLUMnuajXgjzoLiryvdWXARbtZSECNEa63uiBJXmSua8PN8QTleVlVtLpdl/a/Ls8@vSMisT9l4uJR9uYuiLfmPdyL2Ple/HI1Q@JupbzOHZpSl53wFgyJjBCXCIC@QMF2oI8uuVyhpvZIngp/lhRixCCUi@vO6WmA2NjSm31xDayrZDIVyEdcZp4vuL8Fw "Perl 5 ‚Äì Try It Online") - Perl  
[Try it online!](https://tio.run/##bVJdb9swDHzvr@CMDpGSVHUC7GWqUWzDBgxYu6F9TDNAseVErUx7kty4KfLbM8rxPgrULzTJ01F34r16VGf3xcPBVE3tAtxTLkwtxhL@r7TB2FdrTq91R52Tpl1Zk0NulfdwpQzCMww1H1Sg8FibAirqsNvgDK5BubVfLDmEjau3Hj53uW6CqenkCcAXYzWUGept/8sSkdeFFtRPuPzYlqV2urjRqtAOVj3sZZH9OTmkJedymOunQW43kZ8xn61Igyq@GdSM8zcZttZyUzIv9K9WWc@S8/F4nHD@/BJ6ZGAsvErwTAzhLwMRnBPDinAP0k@y0R2OYgxyf6ztf6gQtENw2fBHaqsmDvBckhururZaIeyykhi1hNtcIZJ0g00bIIOodqix2ycfdCUMcgmDzh4mNspf6y7QNXuLAQZDLN2dOI4gJMQgcegvlmCpHVHCN9YElpzRIxA@AKbU@YqB1sCJRjmvKWF2kS75FHD2alNYjeuwuZjDJUQkvKcwWxJjvlFusewGPX2Gs6WED86pJy9KYy3rpqNu1JsCUNYuaqNrZJhKwIsMZxQmExJ4pUK@IYcqYnOiOmas31ykBf9E5MeNEVunGjaMyOvm6Xt5o3CtaVI6Rc6j0hJYReOxIO/i2@74YHJNjm2dCZrFR@VylwXXxvf5127Iw1Cy5K1PyBIu9/E7iVt1@MlYN@F38zG7zO7mp8Q930@600NcmEN69i5NfwM "Java (JDK) ‚Äì Try It Online") - Java  
[Try it online!](https://tio.run/##XVBda8IwFH33V4QQaK5NtRbdkFh82QbC2MO2N@tC7VJbVtOQRiiIv727lT3tIZf7dc65Obayw2ZrK0uYIymhc0pmxDp9Uk7bJi80D@az6VapKm@8KtqzrRvtMp6BzN7nXSBIgK/EpjrpccF4bXzHlXrZvT4rBYIsACmRWE5qU6tOe05t4fTsmBc/3mFQTX2uPRWELpP1cv3wmKxXFOSkbB1ndRpL1qQlsnf84/Np9wYSrqQuOWv2nXeNNphBtDikKc0MBVzuLkecYFvEIlrAiNe9bdpvzWlEBa5LxBftxfgRu0kQtEcCjPFBTgi5K5u/mplNep9jFoaA0oTfHTrnvqg4cwLFRrt07nnQB4IZACDX8cQadFG1412S4FcWkow1YUbeUOb2z1YOcvjivA8hS6Z8m2YJA7gmt7BnwxBHqzj@BQ "PHP ‚Äì Try It Online") - PCRE  
[Try it online!](https://tio.run/##NY7NasMwEAbvfopF5LAb/2C59GJX5EEcF0KrJCrqyqwU6lD67G7k0tuywwzffE/XwE@r@5yDJIj3WIm92KX6iIEHECNKqfUVcSnp2O3xYI7djui7@ymX3fpgo@5rPQ3gTFucg4AHxznTxPTuuC/AG9/E2buEqlZUgDuDt4yeXroe/Kgn48d2KiDLnGU58cWi44QZUPV36YlKTY9eDmwTm2hP8nZFqUAtas8bzNT1MEu2aHsYPfwPCrfUfIlLFmMSZKK1rZ/b9hc "Python 3 ‚Äì Try It Online") - Python `import regex`
This is a port of the now-obsoleted 24 byte "ECMAScript or better" regex, using a possessive quantifier instead of an atomic lookahead to disable backtracking.
```
^                   # tail = input number
(
    (x+)            # \2 = largest strict divisor of tail
                    #    = tail / {smallest prime factor of tail}
    \2*(?=\2$)      # Assert that \2 is a strict divisor of tail; tail = \2
){2}+               # Execute the loop exactly 2 times, with backtracking disabled
x$                  # assert tail == 1
```
### \$\large\textit{Expressions with interactive input}\$
# [R](https://www.r-project.org/), ~~59~~ ~~58~~ 54 bytes
```
grepl('^((.+)\\2*(?=\\2$)){2}+.$',strrep(1,scan()),,1)
```
[Try it online!](https://tio.run/##ZczLCoMwEIXhfZ5D8EwNYtILdSF9ERFEQhEkDTNSCuKzR9ed1YGPw89ZuvBLHETmT8SW3xzSgnIA6or63l/w6s4piDa/V3VRWln5/MBZmcYIImsd5Z1M4jmuCN9xgRAZZ/7FK7kquSl5KHnqTqNDraL2ng8 "R ‚Äì Try It Online") - test cases only
### \$\large\textit{Anonymous functions}\$
# [R](https://www.r-project.org/), ~~63~~ ~~62~~ ~~58~~ 53 bytes
```
\(n)grepl('^((.+)\\2*(?=\\2$)){2}+.$',strrep(1,n),,1)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LY5BasMwEEX3PcVgAp5p5GAZAqVC9ALdd2G7YBrJFQjVaJRNgk_STVrIEXqY3qYS6Wrm8ef_P59f8fJt9fWYbPPwux8w0BzN4rF-RdxtaRi6e3zSeWyIzt263W1qwSnmG5QikBCS_s0_rFsFJ22dN1hxOrhQkQL7EdGDC8DHZYmG-WWKwYWZMZrp8OyCYTxRDr8D8KAhh_PiXUIvoGoq6ns5jgqcBfQmzOkdPWktCXzfjdpnNRtLiSslhR-LQtmBFh0RnPPG9DYlrIdQk2ItFRR0tK635y_Xttm37Q3-AA)
*-1 byte [thanks to Giuseppe](https://codegolf.stackexchange.com/questions/248690/is-it-a-valid-list/248747#comment555846_248747)*  
*-4 bytes by using `grepl()` instead of `sum(grep())` or `any(grep())`*  
*-5 bytes by using a new anonymous function syntax introduced in R v4.1.0*
The old **58 byte** R v3.5.2 function: [Try it online!](https://tio.run/##FU3LasMwELz3KxYT8G4jB8vQixXRH@i9B9sF00iuQKhCqxya4G93pdPMMK902Gt3xPSXxtHilkz02H4hXs40z8MrvusCJ6LnsJ8vp1ZwTiWDUgQSQhIdrHsFD22dN9hwvrnQkAL7m9CDC8D3GJNh/lxTcGFjTGa9fbhgGB9UZl8APGgosxy9y@gFNF1D0ySXRYGzgN6ELf@gJ60lgZ@GRfvilmI9cfWk6rE6VBpo0RHBszCm7zVjO4eWFGupoEpH@3703Vvf/wM "R ‚Äì Try It Online")
# [Ruby](https://www.ruby-lang.org/), ~~37~~ 36 bytes
```
->n{?x*n=~/(?=((x(x*))\2+)\1+$)\3^/}
```
[Try it online!](https://tio.run/##PY7RDoIwDEXf/YpKTNgkGwN9w8mHAJoYAZcshcCIGKO/joWoD23a23tu2g2Xx1TpSRzxmY5b1O@QpZqxkY1bzvM44HkUbHi@O4WvyWiVwP1mbAlW16XrVwCmApuJqNDay9FL6GAzJaWIiwRKvJKDFNm31jjmC59/EWlLrN2N8UNMTEY8YX@kajpAMAizKF1zNixSXMrZ@F/Jt2RVGRJIg1nP/7WD65cc0nREe2fQAf6i5041KbFX6gM "Ruby ‚Äì Try It Online")  
[Try it online!](https://tio.run/##FcZLDoIwFADA/TtFARctRJCPRjSVg4gSP0VJyNPYEitNvXrF1cxrOH9cy918h6bSIfJvQitOqaY6ZKzOIlan0YzV@TGx7n3vekGQ34SSMImxejTdloy83eMByHNQkviBQbshgfG80RI@ZYwv/UlK@6/1QeDVpZBBDgWsYA35AooSyuUP "Ruby ‚Äì Try It Online") - test cases only
# [PHP](https://php.net/), 62 bytes
```
fn($n)=>preg_match('/^((.+)\2*(?=\2$)){2}+.$/',str_pad('',$n))
```
[Try it online!](https://tio.run/##LY89b4MwEIb3/AoLWeKumMQgdTJOlixdurRbSKOU2AHJNRYQqRLit9Nz1OV0X8@974U2rNUhtIFxq1frgXvU@zCY@@XnOjUtpLsvgG2GdfkCB12XHHEul2zLd6kYp@ESrjdIU0EYrmpj@wF4p6XiTtu7mUb4@Dy@vaPCmXUWuDsR4wzJOMyLs9ZJ7ROk5fHxTRNqCynyAiNvfoPrbwaSPBG0rohv@oefIluVBJ3oAEV5VhvGnsr@v@a@0s85ZVmGJM2A2/gbsjn66NA0bR/FFSO/hWKxZtyrZVll/irlHw "PHP ‚Äì Try It Online")
# JavaScript (ES6), ~~46~~ 45 bytes
```
n=>/(?=((.(.*))\2+)\1+$)\3^/.test(Array(n+1))
```
[Try it online!](https://tio.run/##Tc3BTsJAEIDhV0FiYMZNS4ueWKfEIxdewGqysdt2dJ1udhcIAZ691oOJ5y/5/09zNPEjsE9Z9NzY8D3Ilz2PLY1C1Qq2BJBD/oBYrxXWpbrH@vF9lScbE7yEYM4gqkQcIxX61LOzAI6CNY1jsYB4R3JwDi8duTx6xwmW2RI1twBCXe6sdKnHan29ctybPTB5E6LdSYLutXhD/AP7H6Qqt@XmlzH1YTjNd3I0jptZMNLZzWyunG6HAJqfyWpWCqdhC4x4iYuFDzxVUEcqtT@kmMIk@nYbi@ypKH4A "JavaScript (SpiderMonkey) ‚Äì Try It Online")
# Java 8, 61 bytes
```
n->new String(new char[n]).matches("((.+)\\2*(?=\\2$)){2}+.")
```
[Try it online!](https://tio.run/##bVDLbtswELznKxZCCi/9IGQDuYRWguRQoEDbi4@2DoxCWXTplUBS8SPIt7sryW0OLS/L5cwOd2an3/Rs9/rrYvdN7SPsuJdttE6WLRXR1iTHCv4Bx@qmcDoE@KEtwfsNQNO@OFtAiDpyeavtK@wZw1X0lrbrHLTfBtFTAb5etZffKJqt8dPnunZG0wOUkF1o9kDmAMMkdtei0n5NuZB7HYvKBEwQ5URsNosxPmZcboV4X3xMZCIuin94GeTgnJXaBaNgVWgi48FS00bIoNcf3nB1CtHspSWh4FBZZwB7mqx0@GmOEcWftYeNwFkyrDGQiBnf@QF5@q9Xx3DHkqFxNmIySxi1FIFSRq6mZaN9MNygW6e5mALN/wtKZ2gbq@UCHqFjwj2Xec6KfSz58epnCGmeK3jyXp@CLK1zeJyOjiOh@v3L2nfeeI2MUgW0zGjOZTJhg7YELKVuGndC4jRtiWdxjaZmnwdvo8HRhljsnEXfdql@wg07jyUmX0LCRoT66M4lnd2l6W8 "Java (JDK) ‚Äì Try It Online")  
[Try it online!](https://tio.run/##hZHPagIxEMbvfYpBPMxUDHarUhHbJ9CLR/Uwxliju5NlEy0i@@xr7HqVQIb58xu@@SBHvnDflUaOu1Ojc/Ye5mzl9gZgJZhqz9rA4tECbJ3LDQtojAiEpnFax4jPBw5WwwIEZtBI/1vMHyxDZeUXH6U@cLWSDamCgz4Yjx1E1aP1OnvHn1lMXaJbVvdUh5ppK1met3mUfCpfnN1BEZ1hq7raAFNra3n1wRTKnYMqIwq5oCiNH/Rv8CXPEvwzwYcJPk7wr9T9QcrAJLEwGdHzj@rmDg "Java (OpenJDK 8) ‚Äì Try It Online") - test cases only
# Java 11, 51 bytes
```
n->"x".repeat(n).matches("((x+)\\2*(?=\\2$)){2}+x")
```
[Try it online!](https://tio.run/##bZBPb9swDMXv/RSEsSFS/ghOgF2muMV2GDBg2yXHxAfVlWNlCi1IdOOk6GfP6CTtDpsuBPmeHvjjzjyb2e7p99ntQxsJdtyrjpxXdYcVuRbVWMM/4ljfVd6kBD@NQ3i5Awjdo3cVJDLE5bl1T7BnTawoOtyuSzBxm@TFCvDtlr38jmS3Nk6/tq23Bu@hhuKMs/usz1S0wRoSKNXeUNXYJDIh@oncbBZj8VBw@SDly@J10mfyrDn38RoCp6I2PlkNq8og2ggOQ0dQANrD20ysjonsXjmUGg6N8xbExaYak37ZnoR8W/ZKAN6h5YyrCdnxgweCf78TepYHl0rBOxLZLGPVIQHmrNxQVTAxWW6EX@elnALO/ysqb3FLzXIBDzA44TOXecmJVWPiuuxvPJcO56WGLzGaY1K1817001E/kvqyf93GgY3XKDDXgMsC51wmEwZ0NYhamRD8kQ8tuRcneTtNy5yH6MiK0QY57FRQ7Iar/pUDk1Mtso8pYxCpX4d3zmef8vwP "Java (JDK) ‚Äì Try It Online")
### \$\large\textit{Full programs}\$
# [Retina](https://github.com/m-ender/retina), ~~30~~ 29 bytes
```
.+
$*
^(?>((1(1*))\2+)\1+$)\3
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wX0@bS0WLK07D3k5Dw1DDUEtTM8ZIWzPGUFtFM8b4/39DLiMuYy4TLjMuCy5jAy4TSy5LUwA "Retina 0.8.2 ‚Äì Try It Online") - test cases only
# [PHP](https://php.net/), 64 bytes
```
<?=preg_match('/^((.+)\2*(?=\2$)){2}+.$/',str_pad('',$argv[1]));
```
[Try it online!](https://tio.run/##K8go@P/fxt62oCg1PT43sSQ5Q0NdP05DQ09bM8ZIS8PeNsZIRVOz2qhWW09FX12nuKQoviAxRUNdXUclsSi9LNowVlPT@v///yaWAA "PHP ‚Äì Try It Online") - tests one number at a time
# [PHP](https://php.net/) `-F`, 61 bytes
```
<?=preg_match('/^((.+)\2*(?=\2$)){2}+.$/',str_pad('',$argn));
```
[Try it online!](https://tio.run/##VY89b8IwFEXn8ituXRcnBEMK6uQENqRODB2hRW7skKjBiUykVhB@e@rwIVQPlt590n3nfMl91lotFbhVYAw2itjm@lgbzePK6u1mJ@sk89j40/NGgb@eDLx5vJ5Q3z9OTsGIjtlwX9tNJZXH2JBKuzW@L9pbT08nWQluQKglrBvI2hDBMENSKi2gf3WC6az/IrD7TvO0xFLgJ8sLjbfFe4wrIIqmWV16CoIPoUqkpYXnwcSEHotnwsngRARMdJ6fBi44EbggCOCIVNl7OLNQI/43S0RYomkcSl4L5ClWoNLd0gjdpTrT5hI@gh9AD7esa5v1pyLNBQ6x47@rGtItkOY9VRon2f1oUGUV@OIs7vyXd3nehvw1DP8A "Bash ‚Äì Try It Online") - tests ranges of numbers  
[Try it online!](https://tio.run/##K8go@P/fxt62oCg1PT43sSQ5Q0NdP05DQ09bM8ZIS8PeNsZIRVOz2qhWW09FX12nuKQoviAxRUNdXUclsSg9T1PT@v9/E8t/@QUlmfl5xf913QA "PHP ‚Äì Try It Online") - tests one number at a time
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
√ÜfL=2
```
[Try it online!](https://tio.run/##y0rNyan8//9wW5qPrdH/w@2Pmtb8/x9tqKNgpKNgrKNgoqNgqqNgBmQbxAIA "Jelly ‚Äì Try It Online")
# Explanation
```
√ÜfL=2  Main link
√Üf     Prime factors
  L    Length
   =   Equals
    2  2
```
[Answer]
# [Actually](https://github.com/Mego/Seriously), 4 bytes
```
ol2=
```
[Try it online!](https://tio.run/##S0wuKU3Myan8/z8/x8j2/38TSwA "Actually ‚Äì Try It Online")
[Answer]
# 05AB1E, 4 bytes
```
√íg2Q
```
[Try it online!](https://tio.run/##MzBNTDJM/f//8KR0o8D//00sAQ)
**How?**
```
√í       prime factors list (with duplicates)
 g      length
   Q    equal to
  2     2
```
[Answer]
# MATL, 5 bytes
```
Yfn2=
```
**[Try it online!](https://matl.suever.net/?code=Yfn2%3D&inputs=49&version=20.2.2)**
# Explanation
* `Yf` - Prime factors.
* `n` - Length.
* `2=` - Is equal to 2?
[Answer]
# Dyalog APL, 18 bytes
```
‚éïCY'dfns'
2=‚â¢3pco‚éï
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKPdOSM1Ofv/o76pzpHqKWl5xepcRraPOhcZFyTnAwVBKv6DlXAZcnFBGEYwhjGMYQJjmMGlDOByljCWpSkA)
**How?**
`‚éïCY'dfns'` - import `pco`
`3pco‚éï` - run `pco` on input with left argument 3 (prime factors)
`2=‚â¢` - length = 2?
[Answer]
# [Gaia](https://github.com/splcurran/Gaia), 4 bytes
```
·∏çl2=
```
4 bytes seems to be a common length, I wonder why... :P
[Try it online!](https://tio.run/##S0/MTPz//@GO3hwj2///LU0B "Gaia ‚Äì Try It Online")
### Explanation
```
·∏ç     Prime factors
 l    Length
  2=  Equals 2?
```
[Answer]
# [Python](https://docs.python.org/) with [SymPy 1.1.1](http://www.sympy.org), ~~57~~ 44 bytes
-13 bytes thanks to alephalpha (use 1.1.1's `primeomega`)
```
from sympy import*
lambda n:primeomega(n)==2
```
**[Try it online!](https://tio.run/##HYxBDsIgFAXX9hRvVzBfo60a2wRP4gYjaBM/EMqGND07oqt5s3gTcnp71xer7uWj@fHUcGOIExvP5qWFk0p1jY2eMWcOGRMHH9O2WB@RzJwwOYgjoSP0hBPhQrjWfagyEIazHJtNDbok2mXF7oZlbff1zTqJX4Bg/5RSli8 "Python 3 ‚Äì Try It Online")**
[Answer]
# [R](https://www.r-project.org/), 67 bytes
```
c=0;n=scan();for(p in(1:n)[-1:-2]-1)while(n%%p<1){c=c+1;n=n/p};c==2
```
[Try it online!](https://tio.run/##ZcxNCsIwEEDhfU7hpjCDFDvxB9s4JxEXJUQMlGlIRIXSs0fXzvaD93ItHD4ph1LiLLBUz50TLn4UQHefM6RNFKBB8NrS0NpbS/h@xCmANE26EC6e/ZZ@jezS6jyzrSualKM8IbzGCQqiIfMvVsleyUHJSclZfzo96hX1x/oF "R ‚Äì Try It Online")
[Answer]
# Java 8, ~~69~~ 61 bytes
```
n->{int r=1,c=2;for(;r++<n;)for(;n%r<1;n/=r)c--;return c==0;}
```
-8 bytes thanks to *@Nevay*.
[Try it here.](https://tio.run/##hZFNC8IwDIbv/opchBbddH7hqPUf6MWjeKi1SnVLR9YJIvvts35cpZBAkie8eSFXdVeJqwxeT7dOF6quYaMsPnsAFr2hs9IGtu8W4OhcYRSCZgEBchGmbcgQtVfeatgCgoQOk/XzvUIyG2o5EWdHTNBgsELBPzX2aZUJHEniOkkEGd9Q0JVyLNpOfCWr5lgEyZ/y3dkTlMEZ23myeNkfQPGvrd2j9qZMXePTKiBfIMNUs4x/DP7lkwifRvgswhcRvozdH8cM5JGFfM5/P2q7Fw)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 35+8 = 43 bytes
Uses the `-rprime` flag to unlock the `prime_division` function.
```
->n{n.prime_division.sum(&:pop)==2}
```
[Try it online!](https://tio.run/##Hc1NCsIwEEDh/ZxiaEV00aBtFVuIF1EJSFM7YJOQH0VCrm6Urh98z4b7J4/8mquziooZS7MUA73IkVbMhXmz7o02W87rlN8TPSUq5PiQ3jGvBQGgCd5hUUaVeizjeFmJpdxSAVINeQ81NNDCEU7Q7KDtoDt8tfF/3@XKLscf "Ruby ‚Äì Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 3 bytes
```
«ê·∏¢‚ÇÉ
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCLGmyIsIseQ4bii4oKDIiwiO1rGm2AgPT4gYGo74oGLIiwiWzEsMiwzLDQsNiw4LDMwLDQ5LDk1XSJd)
[Answer]
# [Factor](https://factorcode.org/) + `math.primes.factors`, 22 bytes
```
[ factors length 2 = ]
```
[Try it online!](https://tio.run/##NcyxCsIwFEDRPV9xvyCorWIVZ3FxESdxCOXVik2MyXMQ8dtjEZzv4Xau1Xsqx8Nuv13hnfY2pquXbLtfyWR5PCW0krlJCjIQk6i@RhWUtTFvpsyoqFmwpJpQNzRzPqac@D8GCRftR7bhXLyL2PIF "Factor ‚Äì Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), ~~75~~ 65 bytes
```
lambda n:g(n)==2
g=lambda n,i=2:n/i and[g(n,i+1),1+g(n/i)][n%i<1]
```
[Try it online!](https://tio.run/##NcvLCsIwEIXhfZ/ibISGDtTEC7Q4TxKziNTWATsGm41PH4Pg7uM/nPTJj5e6MvO1PON6myJ0XFo1zK5Z@J9I2I3aC6JOvs4knTVku8peTPC6k4sNJd@3vIHhLcERDoQj4VyxrxoIwyk0TXqLZqwxtTPh9zDlCw "Python 2 ‚Äì Try It Online")
All credit to [xnor's answer](https://codegolf.stackexchange.com/a/104632) for the original prime factorization code.
[Answer]
# C#, 112 Bytes
```
n=>{var r=Enumerable.Range(2,n);var l=r.Where(i=>r.All(x=>r.All(y=>y*x!=i)));return l.Any(x=>l.Any(y=>y*x==n));}
```
With formatting applied:
```
n =>
{
    var r = Enumerable.Range (2, n);
    var l = r.Where (i => r.All (x => r.All (y => y * x != i)));
    return l.Any (x => l.Any (y => y * x == n));
}
```
And as test program:
```
using System;
using System.Linq;
namespace S
{
    class P
    {
        static void Main ()
        {
            var f = new Func<int, bool> (
                n =>
                {
                    var r = Enumerable.Range (2, n);
                    var l = r.Where (i => r.All (x => r.All (y => y * x != i)));
                    return l.Any (x => l.Any (y => y * x == n));
                }
            );
            for (var i = 0; i < 100; i++)
                Console.WriteLine ($"{i} -> {f (i)}");
            Console.ReadLine ();
        }
    }
}
```
Which has the output:
```
0 -> False
1 -> False
2 -> False
3 -> False
4 -> True
5 -> False
6 -> True
7 -> False
8 -> False
9 -> True
10 -> True
11 -> False
12 -> False
13 -> False
14 -> True
15 -> True
16 -> False
17 -> False
18 -> False
19 -> False
20 -> False
21 -> True
22 -> True
23 -> False
24 -> False
25 -> True
26 -> True
27 -> False
28 -> False
29 -> False
30 -> False
31 -> False
32 -> False
33 -> True
34 -> True
35 -> True
36 -> False
37 -> False
38 -> True
39 -> True
40 -> False
41 -> False
42 -> False
43 -> False
44 -> False
45 -> False
46 -> True
47 -> False
48 -> False
49 -> True
50 -> False
51 -> True
52 -> False
53 -> False
54 -> False
55 -> True
56 -> False
57 -> True
58 -> True
59 -> False
60 -> False
61 -> False
62 -> True
63 -> False
64 -> False
65 -> True
66 -> False
67 -> False
68 -> False
69 -> True
70 -> False
71 -> False
72 -> False
73 -> False
74 -> True
75 -> False
76 -> False
77 -> True
78 -> False
79 -> False
80 -> False
81 -> False
82 -> True
83 -> False
84 -> False
85 -> True
86 -> True
87 -> True
88 -> False
89 -> False
90 -> False
91 -> True
92 -> False
93 -> True
94 -> True
95 -> True
96 -> False
97 -> False
98 -> False
99 -> False
```
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 17 bytes
```
n->bigomega(n)==2
```
[Try it online!](https://tio.run/##K0gsytRNL/ifpmD7P0/XLikzPT83NT1RI0/T1tbof1p@kUaegq2CoY6CoYGBjkJBUWZeCVBESUHXDkikAZVpav4HAA "Pari/GP ‚Äì Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina), 45 bytes
```
.+
$*
^(11+)(\1)+$
$1;1$#2$*
A`\b(11+)\1+\b
;
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wX0@bS0WLK07D0FBbUyPGUFNbhUvF0NpQRdkIKOyYEJMElokx1I5J4rL@/9@Qy4jLmMuEy4zLgsvYgMvEksvSFAA "Retina ‚Äì Try It Online") Link includes test cases. Explanation:
```
.+
$*
```
Convert to unary.
```
^(11+)(\1)+$
$1;1$#2$*
```
Try to find two factors.
```
A`\b(11+)\1+\b
```
Ensure both factors are prime.
```
;
```
Ensure two factors were found.
[Answer]
# Python 2, 90 bytes
```
def g(x,i=2):
 while x%i:i+=1
 return i
def f(n,l=0):
 while 1%n:l+=1;n/=g(n)
 return l==2
```
`f` takes an integer `n` greater than or equal to `1`, returns boolean.
[Try it online!](https://tio.run/##Rc1NCsIwEAXgfU/xNgWDAzbxBxvJScSdiR0IaYkR4@njdKOzmoHvvVk@ZZqTae3uAx6bSuyMsh3eE0eP2rPlrdMdsi@vnMDd6oK46Ia/0321Udyl7pyUqJ@PzpkW5ozinwWccNUEQ9gTDoQT4Sz7IMdIGI83KZRZMqciT9aMal8)
Test cases:
```
>>> f(1)
False
>>> f(2)
False
>>> f(3)
False
>>> f(4)
True
>>> f(6)
True
>>> f(8)
False
>>> f(30)
False
>>> f(49)
True
>>> f(95)
True
```
]