[Question]
  [
[Sandbox](https://codegolf.meta.stackexchange.com/a/19269/59642)
**Definition:** A positive integer `n` is *almost-prime*, if it can be written in the form `n=p^k` where `p` is a prime and `k` is also a positive integers. In other words, the prime factorization of `n` contains only the same number.
**Input:** A positive integer `2<=n<=2^31-1`
**Output:** a truthy value, if `n` is *almost-prime*, and a falsy value, if not.
**Truthy Test Cases:**
```
2
3
4
8
9
16
25
27
32
49
64
81
1331
2401
4913
6859
279841
531441
1173481
7890481
40353607
7528289
```
**Falsy Test Cases**
```
6
12
36
54
1938
5814
175560
9999999
17294403
```
Please do not use standard loopholes. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the shortest answer in bytes wins!
  
[Answer]
# [Sagemath](https://www.sagemath.org/), 2 bytes
```
GF
```
Outputs via [exception](https://codegolf.meta.stackexchange.com/a/11908/48931).
[Try it online!](https://sagecell.sagemath.org/?z=eJxtjc0KwkAMhO-FvsNeRIU5bDbJ_hS86kOoB9EWBKlSK-jbG1Hx4lwymXxJusWmrlbLuqqr7jy43h17tw5gCDIKKCIoQgIHSEG0lEDMhCCeLCJGzFoMKVkIyiRWiBKLkSkX_6riWTn6hKQhh2yHQPYkQgVUOEMzmUuq0aO8ZW0oYpvbpq6caRweH_dSN-vnv-4yHPtxNp0cGsNu7dRN3Hfc3vftZWz-st3udP3AT22yOJg=&lang=sage&interacts=eJyLjgUAARUAuQ==)
---
The Sagemath builtin \$\text{GF}\$ creates a [Galois Field](https://en.wikipedia.org/wiki/Finite_field) of order \$n\$. However, remember that \$\mathbb{F}\_n\$ is only a field if \$n = p^k\$ where \$p\$ is a prime and \$k\$ a positive integer. Thus the function throws an exception if and only if its input is not a prime power.
[Answer]
# [Python 2](https://docs.python.org/2/), 42 bytes
```
f=lambda n,p=2:n%p and f(n,p+1)or p**n%n<1
```
[Try it online!](https://tio.run/##ZcuxCsIwGEXhPU9xKRSa2sHGLZhXcOjmGGmjAb35iVl8@lgRBXE8cD55lEuiqTW4q7@dZg8O4oxlK/CcEbq1N6NOGdL3bLkf6@Sy53npzLDbaqUkRxY0x@XeqLB@RCQmqxDDi2uL98HP@iWH9C@Yyq@qTw "Python 2 ‚Äì Try It Online")
Since Python doesn't have any built-ins for primes, we make do with checking divisibility.
We find the smallest prime `p` that's a factor of `n` by counting up `p=2,3,4,...` until `n` is divisible by `p`, that is `n%p` is zero. There, we check that this `p` is the only prime factor by checking that a high power of `p` is divisible by `n`. For this, `p**n` suffices.
As a program:
**43 bytes**
```
n=input()
p=2
while n%p:p+=1
print p**n%n<1
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P882M6@gtERDk6vA1oirPCMzJ1UhT7XAqkDb1pCroCgzr0ShQEsrTzXPxvD/fzMA "Python 2 ‚Äì Try It Online")
This could be shorter with exit codes if those are allowed.
**46 bytes**
```
lambda n:all(n%p for p in range(2,n)if p**n%n)
```
[Try it online!](https://tio.run/##ZcuxCsIwGEXhPU9xKRSS4iB1C/QVHLoJLpE2Gog3P2kWnz5apEJxPZxPXuWR2Fc/XGt0z9vkQOti1GwFPmUIApEd77PuDzTBQ7qOLU0dhy2fjkYpyYEFzWVeGrVCrnC0Ch/iNY3F9@C2/sg5/Qumslf1DQ "Python 2 ‚Äì Try It Online")
[Answer]
# [Shakespeare Programming Language](https://github.com/TryItOnline/spl), 329 bytes
```
,.Ajax,.Page,.Act I:.Scene I:.[Enter Ajax and Page]
Ajax:Listen tothy.
Page:You cat.
Scene V:.
Page:You is the sum ofYou a cat.
 Is the remainder of the quotient betweenI you nicer zero?If soLet usScene V.
Scene X:.
Page:You is the cube ofYou.Is you worse I?If soLet usScene X.
 You is the remainder of the quotient betweenYou I.Open heart
```
[Try it online!](https://tio.run/##hZDLCsIwEEV/ZT6gBEQ3diMuXAQKCoIo4iJNpzZiE00m@Pj5mLQFhS7cTS7nzknibtcQMra8iGfGNuKMcZYEPGdbiRrTcFxpQgsJAaErSNQpnfJCOUINZKh5deX8YDxIQUN5l39T5YAaBOdbMHUKRAfyPrbYCqWrqDF1F9y9IYWaoER6IGoOr9jRSkbkjdYseA3OFEjg3SAbpPuxVPoSe2vypUUPY1183HjLnv30/t4qsZytb/ETGhSWQpjNJ9MP "Shakespeare Programming Language ‚Äì Try It Online")
Outputs `0` if the input is almost prime, and a positive integer otherwise. I am not sure this is an acceptable output; changing it would cost a few bytes.
Explanation:
* Scene I: `Page` takes in input (call this `n`). Initialize `Ajax = 1`.
* Scene V: Increment `Ajax` until `Ajax` is a divisor of `Page`; call the final value `p` This gives the smallest divisor of `Page`, which is guaranteed to be a prime.
* Scene X: Cube `Ajax` until you end up with a power of `p`, say `p^k` which is greater than `n`. Then `n` is almost-prime iff `n` divides `p^k`.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 4 bytes
```
Yf&=
```
* For almost-primes the output is a matrix containing only `1`s, which is [truthy](https://codegolf.stackexchange.com/a/95057/36398).
* Otherwise the output is a matrix containing several `1`s and at least one `0`, which is [falsy](https://codegolf.stackexchange.com/a/95057/36398).
[Try it online!](https://tio.run/##y00syfn/PzJNzfb/fxMDY1NjMwNzAA) Or [verify all test cases](https://tio.run/##bY47T8QwEIT7@RVuIJcmyvoR2wWiOZDoKK6hQCICh1g4D8WJ0BX89mByEroTbLPe8bcz29VzWF/Yb12x/VAUxWfrg1ufmuub9fb886FBdpiWuT1m2/y4xJbNrY8szpPv3/F1Tt@F6JDd1yFu@H/88wXfv7Gdb3LsLw7ycQz1EYdz8WQ0LY7tNruu/nAxOTu2nc7CMIzM943v/exysD8xG5anuG4M/tXP@cohIGFgQRW4AtcQHNKiSiqBhCBwWVKSSKAyyibEGklQgmRqRFrIRGpjy58uS6FEVWpoxQ03yQiUQiooCbLCQBlKL61UVcKeKo3cyrT5DQ), including truthiness/falsihood test.
### How it works
```
     % Implicit input
Yf   % Prime factors. Gives a vector with the possibly repeated prime factors
&=   % Matrix of all pair-wise equality comparisons
     % Implicit output
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 11 bytes
```
PrimePowerQ
```
[Try it online!](https://tio.run/##JU1LCoNQELtKDxDwze@9mUXBI9gjSBHrwhZE6KL07Hak2SQTksw67o9pHfflPh7z9Ri2ZZ2G13vabqd@7peun7v@wxAoHAGqYAM3CEMDNV0CiRBYC6VFguoWGQlXgglpElETzWTzKCdrEZNaGpqxs@cQKJ9UmIJCHOaUqpnVgvgjTw7N5vc4fg "Wolfram Language (Mathematica) ‚Äì Try It Online")
@Sisyphus saved 1 byte
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 2 bytes
```
√í√ã
```
[Try it online!](https://tio.run/##yy9OTMpM/f//8KTD3f//mxgYmxqbGZgDAA "05AB1E ‚Äì Try It Online")
### Commented:
```
√í   -- Are all the primes in the prime decomposition
 √ã  -- Equal?
```
[Answer]
# [R](https://www.r-project.org/), ~~36~~ ~~32~~ 29 bytes
*-3 bytes by outputting a vector of booleans without extracting the first element*
```
!(a=2:(n=scan()))[!n%%a]^n%%n
```
[Try it online!](https://tio.run/##K/r/X1Ej0dbISiPPtjg5MU9DU1MzWjFPVTUxNg5I5v03tPgPAA "R ‚Äì Try It Online")
Outputs a vector of booleans. In R, a vector of booleans is truthy iff the first element is `TRUE`.
First, find the smallest divisor `p` of `n`. We can do this by checking all integers (not only primes), as the smallest divisor of an integer (apart from 1) is always a prime number. Here, let `a` be all the integers between `2` and `n`, then `p=a[!n%%a][1]` is the first element of `a` which divides `n`.
Then `n` is almost prime iff `n` divides `p^n`.
This fails for any moderately large input, so here is the previous version which works for most larger inputs:
# [R](https://www.r-project.org/), ~~36~~ 33 bytes
```
!log(n<-scan(),(a=2:n)[!n%%a])%%1
```
[Try it online!](https://tio.run/##K/r/XzEnP10jz0a3ODkxT0NTRyPR1sgqTzNaMU9VNTFWU1XV8L@RuaWFieF/AA "R ‚Äì Try It Online")
Compute the logarithm of `n` in base `p`: this is an integer iff `n` is almost prime.
This will fail due to floating point inaccuracy for certain (but far from all) large-ish inputs, in particular for one test case: \$4913=17^3\$.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 43 bytes
```
f(n,i){for(i=1;n%++i;);n=i<n&&f(n/i)^i?:i;}
```
[Try it online!](https://tio.run/##LU/bTsMwDH3GXxFN6pSoQcv9QlbxIWNIU0eRH8jQ6BNVv704QCTHzjnHJ/b4@D6O2zbxKlEs0@3OcdCldn2PRZQ64LHu98QeULzi8xOWdfu4YOViAawzm09nNrAFjAQrwUlIErIEHSQYTxEJJ84RFhqribOWbuOUbrimtpB8btqcHGHeatey1tG61hBTVr@FU9bboMgzepNMaqaka39T9uSvs6UBfNKtjt4HReP8nQaY7MgD1gK0KONtARxUweMXfr/dJj6Lw39FlCjY9wIePu/0mPiuy1fWXV/qTs4nPEtSUxKiwLr9AA "C (gcc) ‚Äì Try It Online")
Returns `p` if `n` is almost-prime, and `1` otherwise.
```
f(n,i){
    for(i=1;n%++i;);    // identify i = the least prime factor of n
    n=i<n&&f(n/i)^i     // if n is neither prime nor almost-prime
      ?                 //  return 1
      :i;               // return i
}
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 7 [bytes](https://github.com/abrudz/SBCS)
```
‚ä¢‚àä‚ç≥‚àò.‚àß‚ç≥
```
[Try it online!](https://tio.run/##JYw9CsJgEET7nGIuoHy7m5ikFsRUgnqBgKhFQPGnSC2EEIhoIdjY2Ghn4Q08yl4krqYZBubNS9dZZ5an2WrR6PGSjLQ4uUaru5aV1m8tr10tH9aauS1aH7U6fF6ixdnoybhvOR0mk0brG6ab/W6Ze/PPEwyBjwAhIsQgAgmoBwpBMVjAATgExxCC8P9CYp19R97PNUizbauylwMxyAcFoAjswEayweAeOII4iLSSWAwInfsC "APL (Dyalog Unicode) ‚Äì Try It Online")
Uses `‚éïIO‚Üê0`. Returns 0 if the input is almost-prime, 1 otherwise.
### How it works
```
‚ä¢‚àä‚ç≥‚àò.‚àß‚ç≥    ‚çù Input: integer n ‚â• 2
  ‚ç≥‚àò.‚àß‚ç≥    ‚çù Generate a table of LCMs over 0..n-1
‚ä¢‚àä         ‚çù Does the table contain n?
```
The LCM of two numbers is equivalent to taking the maximum of powers in their prime factorizations. If `n = p^k`, any numbers smaller than `n` cannot have `p^k` in their prime factorization, so the LCM table does not contain `n`. Otherwise, we can find a pair of coprime numbers under `n` that multiplies to `n`, so the LCM table is guaranteed to contain at least one copy of `n`.
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), ~~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)?
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHv1kcdXUCkoaHxqGtR3aOOGXqHpz/qXaFp@Kht8qPezZpAFZpAUa1DK4A8IKf2f9qjtgmPevsedTU/6l3zqHfLofXGj9omPuqbGhzkDCRDPDyD/6cpGHGlKRgDsQkQmwGxIVjADAA)
[Answer]
# [J](http://jsoftware.com/), 9 8 bytes
```
1=#@=@q:
```
[Try it online!](https://tio.run/##NU1BCgIxELv3FUEPi6Cl05lpOwuFBcGTJ78ginhY8bivX0fEQEgmJMxz3cThjj5iwB4Jo/MQcbycTyv17dSn97juwtJjBkPQYKCCrMgVnCGG4imBmAlZEnlEjNLUvGJNCMokLkSVxZu1WfqqJFYuqaJqbrlZmHssIP9ToAIybtBG7qpqSbAf/MwmPg7hdn28cMfyN3NYPw "J ‚Äì Try It Online")
*-1 byte thanks to xash*
Tests if the [self-classify](https://code.jsoftware.com/wiki/Vocabulary/eq#monadic) `=` of the prime factors `q:` has length `#` equal to one `1=`
[Answer]
## [Setanta](https://try-setanta.ie/), ~~61~~ 59 bytes
```
gniomh(n){p:=2nuair-a n%p p+=1nuair-a n>1 n/=p toradh n==1}
```
[Try it here](https://try-setanta.ie/editor/EhEKBlNjcmlwdBCAgIDAzs2RCg)
Notes:
* The proper keyword is `gn√≠omh`, but Setanta allows spelling it without the accents so I did so to shave off a byte.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 4 bytes
```
!t{P
```
[Try it online!](https://tio.run/##K6gsyfj/X7GkOuD/f3MjSwA "Pyth ‚Äì Try It Online")
Explanation:
```
P - List of prime factors
{ - Remove duplicate elements
t - Removes first element
! - Would return True if remaining list is empty, otherwise False
```
*-1 byte, thanks to hakr14*
[Answer]
# JavaScript (ES6), 43 bytes
## Without BigInts
Returns a Boolean value.
```
f=(n,k=1)=>n%1?!~~n:f(n<0?n/k:n%++k?n:-n,k)
```
[Try it online!](https://tio.run/##bZG9bsJAEIT7vAUFsk@EcOv78Z2FcccTpCMpLIITsLWOMERKw6sbUJoks1d@N9qd2TnUX/WwPe4/T3Pu33bj2JQpP7YlqXLFU6omlwsXTcpLXfGiLXg6m7UVF/ObRo3bnoe@2z11/XuabJ6P59PH92uiHn7zJs3Uf2KAWCABSARCHlDmEOVoAD1ZHO8FV4QmjEGYWU3CCsLkPrgoWI7B4gBnyAo4D1FbwZnVxhmv7/H//CQvvFnX3SB0hQcloT5UOTwVRYMdukCCMnfOa@z75wnyLNpbNqXGKw "JavaScript (Node.js) ‚Äì Try It Online")
A recursive function that first looks for the smallest divisor \$k>1\$ of \$n\$ and then divides \$-n\$ by \$k\$ until it's not an integer anymore. (The only reason why we invert the sign of \$n\$ when \$k\$ is found is to distinguish between the two steps of the algorithm.)
If \$n\$ is almost-prime, the final result is \$-\dfrac{1}{k}>-1\$. So we end up with \$\lceil n\rceil=0\$.
If \$n\$ is not almost-prime, there exists some \$q>k\$ coprime with \$k\$ such that \$n=q\times k^{m}\$. In that case, the final result is \$-\dfrac{q}{k}<-1\$. So we end up with \$\lceil n\rceil<0\$.
---
# JavaScript (ES11), 33 bytes
## With BigInts
With BigInts, using [@xnor's approach](https://codegolf.stackexchange.com/a/210174/58563) is probably the shortest way to go.
Returns a Boolean value.
```
f=(n,k=1n)=>n%++k?f(n,k):k**n%n<1
```
[Try it online!](https://tio.run/##bdDJDoJAEATQu/9BYEANzTAsRvTmF3hDDwTBBdJjAE38elxO6tT1pZOqrktxL/qyO1@HGetDNY515vC0yYhFtmLL85p1/QaxaFyXLV7SWGrudVvNW3107Hzb3YbTY2@LybfXTsDin6RJoUmJSalJFJkWKGAx6AG6hSAjQu0IdJESaBD6hHIIzBAl6pP/w/aO803R9mBc8DyhwcGdAk9RKsHqKiF0GysV@S8fnw "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# Regex (ECMAScript), ~~35~~ ~~33~~ 32 bytes
*-2 bytes thanks to H.PWiz; the explanation for why this worked was more complicated*  
*-1 bytes by returning to the original algorithm (with its simple explanation), by actually constructing values of \$a\$ not divisible by \$b\$ (32 bytes) instead of asserting \$a\$ is not divisible by \$b\$ (35 bytes); this is slower, but not exponentially so*
```
^(?!(((x+)x+)(?=\2+$)\2*\3)\1+$)
```
[Try it online!](https://tio.run/##TY/LbsIwEEV/BaIKZkgTElp1gWtYdcGGRbtsWsmCwZnWOJZtHuXx7WlYVKp0F1c6V7o6X2qvwsqzi1lwvCa/bew3/bReWjr0Xkm/HB3ASc7Go/YT5n0AOKbYBeaymqR3WE1G1QNWZVfb0fiEeWzeomerAfNgeEXwdJ89IoogC3Go2RCAkZ7U2rAlQOxLuzMGz1qaPDjDEYbZEAVvAKzUuSGrY42zyeXCYamWwNIpH2hhI@j34gPxD9B/YGflvJzeMMbaN4dkYffK8LrnldU07SWpEZvGg@BnSYLTFLvD5JjknhypCIz5VsVVDR7xHAYD1ylFuFmUwu1iiL6biOu1LbOyKIpf "JavaScript (SpiderMonkey) ‚Äì Try It Online")
The 35 byte version was [written in 2014](https://gist.github.com/Davidebyzero/9090628#gistcomment-1177373) by teukon and me.
This works by asserting that there do not exist any \$a\$ and \$b\$, both proper divisors of \$n\$ where \$a>b\$, for which \$a\$ is not divisible by \$b\$.
This will always be true when \$n\$ is of the form \$p^k\$ (a prime power), because we will have \$a=p^c\$ and \$b=p^d\$ where \$k > c > d \ge 0\$, thus \$a\$ will always be divisible by \$b\$.
But if \$n\$ is not of the form \$p^k\$, there will always be at least one counterexample \$a,b\$ such that \$a\$ is not divisible by \$b\$. Trivially we can choose two different prime factors of \$n\$, and they will not be mutually divisible.
This algorithm is similar to that used by [Original Original Original VI's answer](https://codegolf.stackexchange.com/a/220047/17216).
```
# For the purpose of these comments, the input number will be referred to as N.
^(?!              # Assert that the following cannot match
    (             # Capture \1 to be the following:
        ((x+)x+)  # Cycle through all values of \3 and \2 such that \2 > \3 > 1
        (?=\2+$)  # such that \2 is a proper divisor of N
        \2*\3     # Cycle through all values of \1 > \2 that aren't divisible
                  # by \2, by letting \1 = \2 * A + \3 where A >= 0
    )
    \1+$          # where \1 is a proper divisor of N
)
```
---
Bonus: Here is a 28 (27üêå) byte regex that matches numbers of the form \$p^k\$ where \$0 \le k \le 2\$:  
`^(?!((x+)x+)(?!\1*\2+$)\1+$)`, exponential slowdown üêå version: `^(?!((x+)+)(?!\1*\2+$)\1+$)`  
(`(x+)+)` is equivalent to `(x+)x*` but exponentially slower)
[Try it online!](https://tio.run/##TY9PawIxFMS/ii5F33O760ZKD6bRUw9ePLTH2kLQZ/a1MRuS@KdqP/t2PRQKwzDwGxjmUx90XAf2qYieNxR2jfui7zYoR8feC5nnkwc4q9l41H7AvA9wyrFTF1ditJrkd7gSnbWj8RnL1LymwM4AltHymuDxvnhAlFFV8lizJQCrAumNZUeA2Fduby1ejLJl9JYTDIshSt4COGVKS86kGmeT65XjUi@Bldch0sIlMG/VO@IfoP/AzcRcTG8YUx2aY7ZwB2150wvaGZr2stzKbRNA8pMiyXmO3WB2yspAnnQCxnKn07qGgHiJg4HvLiW4vRDS71NMoavIn59WFKKqql8 "JavaScript (SpiderMonkey) ‚Äì Try It Online")
This is interesting because if I'd set out to implement that function intentionally, I would have come up with something like [`^(?=(x?x+?)\1*$)((?=(x+)(\3+$))\4)?\1$`](https://tio.run/##TY/NTsJAFEZfBRsC91JbWiUuGIeuXLBhoUuqyQQu7dVhOpkZoPLz7BVMTFx@OV9ycj7VXvmVYxsSb3lNbtuYL/runDR06L1S9dJagKOcjUfdBxQS2qKNCyzzUR/hd8cI5WPcRywnWJR5vxuNj5iG5i04NhVg6jWvCJ7ukwmi8DITh5o1AWjpSK01GwLEO2l2WuOpkjr1VnOAYTJEwRsAI6tUk6lCjbOH85n9Qi2ApVXO09wEqJbZO@IfoP/AzPIin94whto1h2hu9krzuueUqWjai2ItNo0Dwc@SBMcxXoVRG6WOLKkAjOlWhVUNDvHkBwN7TQpwq8iF3QUf3PUiLpcuS/Isy34A "JavaScript (SpiderMonkey) ‚Äì Try It Online") (38 bytes), which is 10 bytes longer.
It was inspired by the algorithm used by [Bubbler's APL answer](https://codegolf.stackexchange.com/a/220062/17216). The full prime power version of that would be:  
[`^(?!((x+)(?=\2+$)x+)(?!\1*\2+$)\1+$)`](https://tio.run/##TY9Lb8IwEIT/CkQV7JImJKjqAddw6oELh/ZYWsmCxdnWOJZtHuXx29OAhNTLaEbfSKP5VjsVlp5dzILjFflNbX/ot/HS0r7zRvr14ACOcjIcNF8w7QIcUoSpXIzSB7zZ7qIc3NKibKUZDI@Yx/o9erYaMA@GlwTPj9kTogiyEPuKDQEY6UmtDFsCxK60W2PwpKXJgzMcoZ/1UfAawEqdG7I6VjgZnc8c5moOLJ3ygWY2gv4oPhHvgP4DOymn5fiKMVa@3iczu1OGVx2vrKZxJ0mNWNceBL9IEpym2A4mhyT35EhFYMw3Ki4r8Iin0Ou59lKE64tSuG0M0bcVcbk0ZVYWRfEH "JavaScript (SpiderMonkey) ‚Äì Try It Online") - ECMAScript, 36 bytes  
[`^(?!((x+)x+)\B(?>\1*?(?<=^\2+))$)`](https://tio.run/##ZVBNaxsxEL3nV8imYE33g11DL1Vkhyw9BBIS6kAPdQPqeuIIZO2i0bqKN/ntrryb5JJBl@G90fuoKasbh0erdkitqpGtnsnjru9I2y2rZNVYagyKcb/H4POfuO2Mcj9C65BIR4KojSJiu5688rpm@0Zv2I3SlnHo98oxkhfT4wNfTjgPCcS3vuTLxbr8uuTLc/mwnicAX@A4FSeykxb/saiCgVO@6v6Sd1Gclynl12i3/imbQzrgt60/6edVs2u1wQ2IkcuMeGwc19YzKwvBjayibbW51hY5wETazhhhZQm9fuR2UUCV/3La40gYbLTS5KvWaM9n2QzE6S@dojiLB@2bj8X85WUSgfzePd8pR8jb38WftOkiFT5D72dZOXIQ3mX59MrulYmtOWW3@J31xes0NSDQEA4NhqGU1djELMxSDR8RDzGiPpcodJKkIZERhujS5Vd0o3z9xAMMOQ@fch5kKT4sDJrhzSOI12GOZfatKP4D) - .NET, 33 bytes  
[`^(?!((x+)+)\B(?>\1*?(?<=^\2+))$)`](https://tio.run/##ZZBPT@MwFMTv@yncCql@mz9qKnHBuF1txAEJtGiLxIEukkkfxZLrRH5OMQ189q6bABd8s2bs@c1UlFW1w4NVW6RGVciWr@Rx27Wk7YaVsqwt1QbFcL/F4PO/uGmNchehcUiko0FURhGxbUdeeV2xXa3X7Fppyzh0O@UYyV/jwwNfjDgPCSSw@s0X81Xxc8EX5/JhNUsATuAwFkevkxZfWAzBwClfto/kXczmRUr5FdqNf85mkPb6n8Yf4/Oy3jba4BrE4GVGPNWOa@uZlVPBjSwjtVpfaYscYCRta4ywsoBOP3E7n0KZ3zntcTD0GI00@bIx2vNJNgFx/EunKH7EB80Hx3z29jaKQn7rXm@UI@TN/fRfWrfRCt@lz2dZMXgQPmP5@NLulImjOWU3eMa66fs4NSDQEPYDhn6U5bDEJExSDV8V97GiPpcodJKkIZFRhkjp8ku6Vr565gH6nvtvPfeyEF8IfWb4YATx3p9Dkc1O/wM) - .NET, 32 bytes, üêå exponential slowdown
And [user41805's APL answer](https://codegolf.stackexchange.com/a/220353/17216) ported to regex is:  
[`^(?!(xx+)\1*(?=\1*$)x(xx+)\2*$(?<=^\2+))`](https://tio.run/##TY7BbsIwEER/pY2QvEuIFXOMMTn1wIVDeyxFWIkJW7lOahuIBHx7GlpV4rIa7ZvdmU990qHy1MXMtbUZgsqlV6@meek7eIueXMO9Pu@GLZTP0PcpbsQUSjXOCfZ/i/l0AuVCbTfzFHHY8WCpMiBmmUCU3nwfyRtg3ujakjMMeTXqaFYuGr/Xo/VCrjvGovNtZULgIdbkbshbB@z3YmbV8tIoy0NnKQLLGEraAzjVcGtcEw@4nF@vFNZ6DaQ67cP9OzTv@QfiPzCPwC1FKYo7xnjw7TlZuZO2VD957RpTPCWplfvWg6SFMpLSFMfApE@4N91YHgj5l47VATzi5aF4e4z87CkagFCyjWMFY5gSyqCEvN1wEJnI8/wH "JavaScript (Node.js) ‚Äì Try It Online") - ECMAScript 2018, 40 bytes  
`^(?!(?*(xx+)\1*$)(xx+)\2*(?=\2*$)x\1*$)` - ECMAScript + `(?*)`, 39 bytes
The algorithm used by 10+ of the other answers (that all the prime factors are the same / there is only one prime factor), ported to regex is:  
[`^(?=(xx+?)\1*$)(?!(\1x+)(?<!^\3+(xx+))\2*$)`](https://tio.run/##Tc69bsIwFAXgV4Goku9tiBXTLcZk6sDC0I5NEVZiwq1cJ7UNRAKenYZKldiO9N2f86WPOtSe@pi5rjG3oHLp1ZtpX4ce3qMn13KvT9vbBkoFw5CWWInnJ4RyCpUY0jEsppvqJb0bYjUf7bblwVJtQMwygSi9@TmQN8C80Y0lZxjyeszRrFw0fqfH0TO5/hCL3ne1CYGH2JC7Iu8csL@NmVXLc6ssD72lCCxjKGkH4FTLrXFt3ONyfrlQWOs1kOq1D/fr0H7kn4j/YB7BLUUpijtj3PvulKzcUVtqJl671hSTJLVy13mQtFBGUpri@DAZEu5NP5YHQv6tY70Hj3h@KN4dIj95igYglKxyrGAMU0IZlJDXK97mmcjz/Bc "JavaScript (Node.js) ‚Äì Try It Online") - ECMAScript 2018, 43 bytes
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), ~~41~~ ~~39~~ 38 bytes
```
.+
$*
^(?!(((1+)1+)(?=\2+$)\2*\3)\1+$)
```
[Try it online!](https://tio.run/##DYoxCsMwEMB2/aKQwDmGwN05bjyUjPmECc2QoUuH0v87Bg1C6Hf9P9@zjbK/2xwZJg7ZHiKiMXRke1WLQ6g2VQ9Vu7ZmOImVgmZswZ64kQq5V0XdlYz2LbMktPh6Aw "Retina 0.8.2 ‚Äì Try It Online")
[Answer]
# GAP 4.7, 31 bytes
`n->Length(Set(FactorsInt(n)))<2`
This is a lambda. For example, the statement
`Filtered([2..81], n->Length(Set(FactorsInt(n)))<2 );`
yields the list `[ 2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19, 23, 25, 27, 29, 31, 32, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 81 ]`.
[Try it online!](https://tio.run/##S08s@B9QlJlXouGWmVOSWpSaohFtpKdnYRir8z9P184nNS@9JEMjOBUon5hckl9U7AlUmqepqWlj9F9T0/o/AA)
[Answer]
# [Factor](https://factorcode.org/), 35 bytes
```
: f ( n -- ? ) factors all-equal? ;
```
[Try it online!](https://tio.run/##VU@7TsNAEOznK7aEwpb33ucUKVGaNIgKUVjm7ERcbGM7BYr4drOAKNhmZkcz@@iadh3n7enxcHyo6S3NQ8o0zWldP6b5PKx0adZTKfSSlrL7MS/Uz@N1Og89Len9moY2LbTD4VhTO76mfszdVlNHdzRQUdCe7ukv2ORcSKTJe9ptN1LQMAiIYAdloTy0golwojJYa4YyFYvEGi7YKJYYDMNqNgLMXhtx@hCrbzSVttpVHt6qoEKkT3qWS17ki4lK4EYOLFsdrAFHHWADC/PWugrxt6RV0cio/@ntCw "Factor ‚Äì Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 36 bytes
```
f n=mod(until((<1).mod n)(+1)2^n)n<1
```
[Try it online!](https://tio.run/##DcdBCoAgEADAr@yhgxKJeq6XRIGYlrRuYvb9tuY2h7vPgMgcgaZ8beKhllCI0Uj1F0iK3ki7kqTRcHaJYIJSEzXoICZsoUKE2SpltF749RHdfvPgS/kA "Haskell ‚Äì Try It Online")
**36 bytes**
```
f n=and[mod(gcd d n^n)n<2|d<-[1..n]]
```
[Try it online!](https://tio.run/##BcExDoAgEATAr2xhoQUErfUlBBPCiRLhJGjp2z1nDn@fW84iEbx4Jlsu6vdAIPDKA8/TS7Oyo9bsnBSfGAtqS/ygQ0z52Roi7KT1aIyTL8Ts91tUqPUH "Haskell ‚Äì Try It Online")
**39 bytes**
```
f n=all((`elem`[1,n]).gcd n.(^n))[2..n]
```
[Try it online!](https://tio.run/##FclBCoAgEADAr@yhg0KJdvclYiSmJm2LpO9vo7nOGfqVEJkzkA2IQuwJ0707M5OXqsQDSImNpHSrUuT5DpXAQnsqDZggVxzpgQx/G609vzFjKJ2X2NoH "Haskell ‚Äì Try It Online")
**39 bytes**
```
f n=mod n(n-sum[1|1<-gcd n<$>[1..n]])<1
```
[Try it online!](https://tio.run/##DcgxDoAgDADAr3Rw0AFincGPEAaCoESoRHTz7VZvvM21PeTMHIF0ORagnkS7i8EHlVj9H6qbDUpJ1g4KubhEoKGeiS7oIKZ8hRMimElKHEfLr4/ZrY2Fr/UD "Haskell ‚Äì Try It Online")
**40 bytes**
```
f n=and[mod(p^n)n<1|p<-[2..n],mod n p<1]
```
[Try it online!](https://tio.run/##FcpBDkAwEAXQq/yFBQmi1u1JpJKGlkaNCV06u8H25a3u2nxKIgFkHM3Dfswlj1SRVjfrZujblmz9KQislZXdRYIBn5EyCoSYsj8R8E/VdVaeKSS3XNJMzC8 "Haskell ‚Äì Try It Online")
[Answer]
# [Io](http://iolanguage.org/), 48 bytes
Port of @RobinRyder's R answer.
```
method(i,c :=2;while(i%c>0,c=c+1);i log(c)%1==0)
```
[Try it online!](https://tio.run/##nY1NDoMgGAX37xSExARSF36AVmvoEXoCN5ZiJcGfqE2PbzlD3@7NYiYs58BulnXn5I9xeYmQu/RV@x1D9CJk7l7kzroLyTawuLyFkxlZW8iTK2gY1GhAFVQJdYVWMA2qRAmkNUGZghIizdm@xnAI3s1csqlfRb8/PtPTb5INy@Z7N6Y2WNoggmTrFuYjzpDgFSilKpQG1OgaZU3mb935Aw "Io ‚Äì Try It Online")
## Explanation
```
method(i,            // Take an input
    c := 2           // Set counter to 2
    while(i%c>0,     // While the input doesn't divide counter:
        c=c+1        //     Increment counter
    )
    i log(c)%1==0    // Is the decimal part of input log counter equal to 0?
)
```
[Answer]
# [Assembly (MIPS, SPIM)](https://github.com/TryItOnline/spim), 238 bytes, 6 \* 23 = 138 assembled bytes
```
main:li$v0,5
syscall
move$t3,$v0
li$a0,0
li$t2,2
w:bgt$t2,$t3,d
div$t3,$t2
mfhi$t0
bnez$t0,e
add$a0,$a0,1
s:div$t3,$t2
mfhi$t0
bnez$t0,e
div$t3,$t3,$t2
b s
e:add$t2,$t2,1
b w
d:move$t0,$a0
li$a0,0
bne$t0,1,p
add$a0,$a0,1
p:li$v0,1
syscall
```
[Try it online!](https://tio.run/##fY/BDsIgDIbvfYodduwBUKPyNiCoJDBJIFv05bFlusSLh6bN369/25JDai2ZMOkYxlngAcqzXEyMkB6zH@sOSQXqGYE9V4UKFm1vlUsGHLgwd7IqSNc7MQLs5F@U0YNxjoc5JBT9l92aK2CHAl6zQV@lyMAOCzi93tZNt9vIhSWJ@Xdl/nwmv5@1po7n016@AQ "Assembly (MIPS, SPIM) ‚Äì Try It Online")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 2 bytes
Are all prime factors equal?
```
·∏ã=
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//@GObtv//w2NjQ0B "Brachylog ‚Äì Try It Online")
[Answer]
# [APL (Dyalog Unicode) 17.0](https://www.dyalog.com/), 7 bytes
```
‚ç∏2‚åä/‚ä¢‚à®‚ç≥
```
[Try it online!](https://tio.run/##JU07TkNBDOw5xVwAsV7bu@u0NNASLhAJ5TWRoEWIChShBxtBQUkDTToKhESdo/giDwem8Fjz0SyuVocX14vV5TBN3n@yP41HPr77w9b71zT4@tn7xse73Sf7@sU3r/Oz47jnJ6fzaRnuDdFslvzxnnz8GLx/3x4sd9sMhqDBQAVZkSs4QwwlVAIxE7IkCokYpalFxJoQlEmCiCpLJGuz9MeaW24G72@SWLmkut8poJgqUAEZN2ij@KpqSbB/7CtUs0n0fgE "APL (Dyalog Unicode) ‚Äì Try It Online")
Uses a different approach from [Bubbler's answer](https://codegolf.stackexchange.com/a/220062), but only works for Dyalog 17.X. Errors with a domain error on non-prime powers, and doesn't error on truthy inputs.
The train is decomposed as the following
```
‚îå‚îÄ‚î¨‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îê
‚îÇ‚ç∏‚îÇ‚îå‚îÄ‚î¨‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚î¨‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îê‚îÇ
‚îÇ ‚îÇ‚îÇ ‚îÇ‚îå‚îÄ‚î¨‚îÄ‚îê‚îÇ‚îå‚îÄ‚î¨‚îÄ‚î¨‚îÄ‚îê‚îÇ‚îÇ
‚îÇ ‚îÇ‚îÇ2‚îÇ‚îÇ‚åä‚îÇ/‚îÇ‚îÇ‚îÇ‚ä¢‚îÇ‚à®‚îÇ‚ç≥‚îÇ‚îÇ‚îÇ
‚îÇ ‚îÇ‚îÇ ‚îÇ‚îî‚îÄ‚î¥‚îÄ‚îò‚îÇ‚îî‚îÄ‚î¥‚îÄ‚î¥‚îÄ‚îò‚îÇ‚îÇ
‚îÇ ‚îÇ‚îî‚îÄ‚î¥‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚î¥‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îò‚îÇ
‚îî‚îÄ‚î¥‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îò
```
First a range from 1 to the right argument is created using `‚ç≥`.
```
      (‚ç≥) 10
1 2 3 4 5 6 7 8 9 10
```
Then each value in this list is [GCD](https://en.wikipedia.org/wiki/Greatest_common_divisor)ed `‚à®` with the right argument `‚ä¢`.
```
      (‚ä¢‚à®‚ç≥) 10
1 2 1 2 5 2 1 2 1 10
```
Then the pairwise minimum is taken, with the pairs overlapping, so `2‚åä/1 3 2` is equivalent to `(1‚åä3)(3‚åä2)`.
```
      (2‚åä/‚ä¢‚à®‚ç≥) 10
1 1 1 2 2 1 1 1 1
```
Monadic `‚ç∏` in Dyalog 17.0 is a function that finds the indices of truthy values given a binary array, but this function of it is irrelevant for this solution. If the input is not a prime power, it will have at least one number greater than 1 when the above is performed (proof below). Otherwise if it is a prime power, the above will result in a list with only 1s. So applying `‚ç∏` on a non-prime power will cause the function to error because its argument is not a binary array, whereas on a prime power it won't error because the argument would binary consisting only of 1s.
In Dyalog 18.0 `‚ç∏` has been extended to also accept non-binary arrays, so the above won't work. Instead, using 'unique' `‚à™` in place of `‚ç∏` will return the 1-length vector consisting only of 1 for truthy values, and a longer vector for falsey values.
[Bubbler](https://codegolf.stackexchange.com/users/78410) gave the following proof as to why `2‚åä/‚ä¢‚à®‚ç≥` does not give a vector of 1s for falsey values.
Consider the Diophantine equation \$p\_1a-p\_2b=1\$, where \$p\_1\$ and \$p\_2\$ are distinct prime factors of a non-prime tower \$N\$ and \$a,b>0\$. This equation has solutions, a proof of which can be found in the following [Wikipedia article](https://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity). What this equation means is that you will have a situation where a multiple of \$p\_1\$ occurs as the number immediately following a multiple of \$p\_2\$. Since each prime factor divides the input \$N\$, their multiple, when GCDed with the input, will result in a value greater than 1. The fact that these multiples are less than \$N\$ is left as an exercise to the reader. So the two multiples of prime numbers following one another and that these multiples are less than \$N\$ mean that you have a situation where `2‚åä/‚ä¢‚à®‚ç≥` will have a number greater than 1 in it.
This situation does not occur for prime powers because given any two prime factors \$p^m\$ and \$p^n\$ where \$n>m\$, there will never be a situation where \$p^na-p^mb=1\$ because that would imply \$p(p^{n-1}a-p^{m-1}b)=1\$, i.e. that \$p\$ divides 1 which is false.
[Answer]
# Java, ~~69~~ 64 bytes
```
n->{int f=0,t=1;for(;n%++t>0;);for(;n>1;n/=t)f|=n%t;return f<1;}
```
-5 bytes thanks to *@Deadcode*.
[Try it online.](https://tio.run/##LVDBjoIwEL37FRMTEwijS2kLrV38g/Xi0XioCBtcLAaqm43Lt7PDag@dvtfXN69ztne7PJ@@xqKxfQ8ftnaPGUDtfNlVtihhO0GAY9s2pXVQBHQFLjTEDjPaem99XcAWHOQwuuXmMQmqPEafM1O1XWDcIor8JjbhC26YcW@5D6vf3C286Up/6xxU78wMo5k8r7djQ54v63tbn@BCwYKd72r3uT@ADZ@pJr@pXb125fcUen94JMhRoEKNLMVEYpIhT1BoTIllyDhnmIiYEcU4pkpqkmglGErOBBXGMi5ImSkdT1XEXPI0zjCTiUoUGSGjJilKgUxzhVIxOmVSpjHq5yKYaEEvh/A/KMDup/flZdXe/OpKv/CNC@povoZ55FY01PA10WH8Aw)
**Explanation:**
```
n->{             // Method with integer parameter and boolean return-type
  int f=0,       //  Flag-integer `f`, starting at 0
      t=1;       //  Temp integer `t`, starting at 1
  for(;n%++t>0;);//  Increase `t` by 1 before every iteration with `++t`,
                 //  And continue looping until the input `n` is divisible by `t`
  for(;n>1;      //  Then start and continue a second loop as long as `n` is not 0 or 1:
      n/=t)      //    After every iteration: divide `n` by `t`
    f|=          //   Bitwise-OR the flag by:
       n%t;      //    `n` modulo-`t`
  return f<1;}   //  After both loops, return whether the flag is still 0
```
---
If we would be allowed to ignore floating point inaccuracies, a port of [*@RobinRyder*'s R answer](https://codegolf.stackexchange.com/a/210175/52210) would be **64 bytes** as well:
```
n->{int m=1;for(;n%++m>0;);return Math.log(n)/Math.log(m)%1==0;}
```
[Try it online.](https://tio.run/##PVDLbsIwELzzFatKSImypPErsYnCH5QLR8TBhEBDEwclhqpC@Xa6Kag@eB@enRnv2d7s4nz4epSNHQb4sLW7zwBq56v@aMsK1lMJsO@6prIOyoCewIU5dccZXYO3vi5hDQ4KeLjF6j4B2oLlx64PcjePonaV5GHeV/7aO1Lwn3HTnQIXvv/nbThnRZHk4yOfOC/XfUOcL@pbVx@gJWPBxve1O213YMOnq0likquXrvqeTG93d44CJWo0yFLkCnmGgqM0mFKXIROCIZcJoxYTmGplCGK0ZKgEkxQYy4QkZKZNMkWZCCXSJMNMcc01ESEjkRSVRGaERqUZZZlSaYLmeajkRtLkGP4ZBdj8DL5q4@7q4wv9wjcuqKO3JbxFLqalhq@Njo9f)
**Explanation:**
```
n->{               // Method with integer parameter and boolean return-type
  int m=1;         //  Minimum divisor integer `m`, starting at 1
  for(;n%++m>0;);  //  Increase `m` by 1 before every iteration with `++m`
                   //  And continue looping until the input `n` is divisible by `m`
  return Math.log(n)/Math.log(m)
                   //  Calculate log_m(n)
         %1==0;}   //  And return whether it has no decimal values after the comma
```
But unfortunately this approach fails for test case `4913` which would become `2.9999999999999996` instead of `3.0` due to floating point inaccuracies (it succeeds for all other test cases).  
A potential fix would be **71 bytes**:
```
n->{int m=1;for(;n%++m>0;);return(Math.log(n)/Math.log(m)+1e9)%1<1e-8;}
```
[Try it online.](https://tio.run/##PVDBbsIwDL3vKywkpFY1rG6SNqGDP4ALR8QhQGFlbYrawDShfjtzB1oOsf3y7Pfis73Zyfnw9dhXtutgaUt3fwMonS/ao90XsBpKgF3TVIV1sA/4CVyYM9q/8dV568s9rMDBHB5usrgPhHpO@bFpg9yNo6hexHmYt4W/ti5YWv85rZpT4ML3/7wOIypMOKYPKiY67x/5MPpy3VU8@qVwa8oD1OwvWPu2dKfNFmz4NDcoDarlzBXfg/fN9p6gQIkaDVKKicIkQ5GgNJgySkhCECYyJoZIYKqVYYrRklAJkhyIMiGZmWkTD1HGQok0zjBTiU40D0JikRSVRDJCo9LEWaZUGqN5Hi4TI7mzD/@MAqx/Ol/U0@bqpxf@ha9cUEajGYwiN@Xdhq/F9o9f)
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), ~~50~~ 43 bytes
```
.+
$*
^(?=(11+?)\1*$)((?=(1+)(\3+$))\4)*\1$
```
[Try it online!](https://tio.run/##HYsxDkIhEAX7dw5MdiEx/7ELQmF@@S9BjBYWNhbG@yOxnJnM5/l9vR/zJMd9nhNCxE32q5Bp18EYVP6YVIaloDpc42CYM8PgaOhgRS7IF1iGd9RlCZoR2TcuRUNtZRVwXRXFwW4NpdF/ "Retina 0.8.2 ‚Äì Try It Online") Link includes faster test cases. Originally based on @Deadcode's answer to [Match strings whose length is a fourth power](https://codegolf.stackexchange.com/q/19262/17602), but saved 7 bytes thanks to @Deadcode by improving the basic algorithm. Explanation:
```
.+
$*
```
Convert the input to unary.
```
^(?=(11+?)\1*$)
```
Start by matching the smallest factor `p` of `n`. (`p` is necessarily prime, of course.)
```
(?=(1+)(\3+$))
```
Find `n`s largest proper factor `m`, which is equivalent to `n` divided by its smallest prime factor `q` (which will be equal to `p` on the first pass).
```
\4
```
The factorisation also captures `n-m`, which is subtracted from the current value of `n`, effectively dividing `n` by `q` for the next pass of the loop.
```
(...)*\1$
```
Repeat this division by the smallest prime factor until `n` becomes `p`, which is only possible if `n` is a power of `p`.
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 10 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
‚ïíg¬∂m√âk‚ïí#‚îÄ‚ïß
```
Port of [*@Razetime*'s APL (Dyalog Classic) answer](https://codegolf.stackexchange.com/a/210173/52210), so make sure to upvote him as well!
[Try it online.](https://tio.run/##y00syUjPz0n7///R1Enph7blHu7MBrKUH01peDR1@f//RlzGXCZcFlyWXIZmXEamXEbmXMZGXCaWXGZAUUMuMy5DoAozLlMTAA)
**Explanation:**
```
‚ïí           # Push a list in the range [1, (implicit) input-integer)
 g          # Filter it by:
  ¬∂         #  Check if it's a prime
   m        # Map each prime to,
    √â       # using the following three operations:
     k‚ïí     #  Push a list in the range [1, input-integer) again
       #    #  Take the current prime to the power of each value in this list
        ‚îÄ   # After the map, flatten the list of lists
         ‚ïß  # And check if this list contains the (implicit) input-integer
            # (after which the entire stack joined together is output implicitly)
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
I feel like this should be 1 or 2 bytes shorter ...
```
k √§¬∂ √ó
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=ayDktiDX&input=WzIKMwo0CjgKOQoxNgoyNQoyNwozMgo0OQo2NAo4MQoxMzMxCjI0MDEKNDkxMwo2ODU5CjI3OTg0MQo1MzE0NDEKMTE3MzQ4MQo3ODkwNDgxCjQwMzUzNjA3Cjc1MjgyODkKNgoxMgozNgo1NAoxOTM4CjU4MTQKMTc1NTYwCjk5OTk5OTkKMTcyOTQ0MDMKXS1t) - includes all test cases
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
√ÜfE
```
[Try it online!](https://tio.run/##JY6xDQIxDEV7z@Iiju3EGQAxBKKE4nQLXEsByzAC3YlFWCR8Q6TE1vv5/l4u67rNud@vh/l@7Y/P7Xmc80SVSZmMKZgGkzSm6rgdHJqBtVQFmireakWSC2wtfOTfEQbmKpZVpKuloccov8aKuraCmd1r1ICJECQZjuoIkKHYwEOy7@6tYJ//SVCHYQjT@Qs "Jelly ‚Äì Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 8 bytes
```
‚à®/1~‚ç®‚ä¢‚à®‚ç≥
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24RHHSv0Dese9a541LUIyH7Uu/n/f/WQotKSjEorda40BSMgNgZiEyC2AGJLIDY0A0mYgghzkDRIjQlIwgysyhCkxNjYkItL3S0xpxhiDkiLIdgwEMsUpNDQ0hhkoqmFoQkA "APL (Dyalog Unicode) ‚Äì Try It Online")
Outputs 1 if it isn't almost-prime, some other positive integer otherwise.
```
‚à®/1~‚ç®‚ä¢‚à®‚ç≥
     ‚ä¢‚à®‚ç≥   ‚çù All divisors
  1~‚ç®     ‚çù Remove 1
‚à®/         ‚çù GCD
```
[Answer]
# [Pyt](https://github.com/mudkip201/pyt), 4 bytes
```
œº≈Å1=
```
[Try it online!](https://tio.run/##K6gs@f///J6jjYa2//8bAgA "Pyt ‚Äì Try It Online")
```
œº         Implicit input; get unique œºrime factors
 ≈Å        ≈Åength of array
  1=      equals 1?; implicit print
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), ~~18 16 13~~ 11 bytes
*Thanks to [The Thonnu](https://codegolf.stackexchange.com/users/114446/the-thonnu) for -7 bytes*
```
∆õ?$·∏ä$√¶‚àß;‚àë1=
```
[Run it](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLGmz8k4biKJMOm4oinO+KIkTE9IiwiIiwiMjUiXQ==)
Explanation:
```
∆õ      ;    # map over the input with this code:
 ?          # get input
  $         # swap
   ·∏ä        # divisible?
    $       # swap
     √¶      # is the item prime?
      ‚àß     # logical and
        ‚àë   # sum
         1= # is 1?
```
]