[Question]
  [
For a *positive* integer `n` with the prime factorization `n = p1^e1 * p2^e2 * ... pk^ek` where `p1,...,pk` are primes and `e1,...,ek` are positive integers, we can define two functions:
* `Ω(n) = e1+e2+...+ek` the number of prime divisors (counted with multiplicity) ([A001222](http://oeis.org/A001222))
	+ `ω(n) = k` the number of distinct prime divisors. ([A001221](http://oeis.org/A001221))
With those two functions we define the *excess* `e(n) = Ω(n) - ω(n)` ([A046660](http://oeis.org/A046660)). This can be considered as a measure of how close a number is to being squarefree.
### Challenge
For a given positive integer `n` return `e(n)`.
![](https://i.stack.imgur.com/gULhZ.png)
### Examples
For `n = 12 = 2^2 * 3` we have `Ω(12) = 2+1` and `ω(12) = 2` and therefore `e(12) = Ω(12) - ω(12) = 1`. For any squarefree number `n` we obivously have `e(n) = 0`. The first few terms are
```
1       0
2       0
3       0
4       1
5       0
6       0
7       0
8       2
9       1
10      0
11      0
12      1
13      0
14      0
15      0
```
[Some more details in the OEIS wiki.](http://oeis.org/wiki/Omega(n),_number_of_prime_factors_of_n_(with_multiplicity))
  
[Answer]
# [MATL](http://github.com/lmendo/MATL), ~~7~~ 5 bytes
```
Yfd~s
```
[Try it online!](http://matl.tryitonline.net/#code=WWZkfnM&input=MTI) Or [verify all test cases](http://matl.tryitonline.net/#code=IkAKWWZkfnM&input=MToxNQ).
### Explanation
```
Yf    % Implicit input. Obtain prime factors, sorted and with repetitions
d     % Consecutive differences
~     % Logical negate: zeros become 1, nonzeros become 0
s     % Sum. Implicit display
```
[Answer]
# [Brachylog](http://github.com/JCumin/Brachylog), 11 bytes
```
$pPd:Pr:la-
```
[Try it online!](http://brachylog.tryitonline.net/#code=JHBQZDpQcjpsYS0&input=OA&args=Wg)
### Explanation
```
$pP            P is the list of prime factors of the Input
  Pd           Remove all duplicates in P
    :Pr        Construct the list [P, P minus duplicates]
       :la     Apply "length" to the two elements of that list
          -    Output is the subtraction of the first element by the second one
```
[Answer]
# Mathematica, 23 bytes
```
PrimeOmega@#-PrimeNu@#&
```
Very boring. `FactorInteger` already takes up 13 bytes, and I can't see much that can be done with the remaining 10.
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 5 bytes
```
ÆfI¬S
```
[Try it online!](http://jelly.tryitonline.net/#code=w4ZmScKsUw&input=&args=MTI)
[Verify all testcases.](http://jelly.tryitonline.net/#code=w4ZmScKsUwoxNVLDh-KCrFk&input=)
Port of [Luis Mendo's answer in MATL](https://codegolf.stackexchange.com/a/91422/48934).
```
ÆfI¬S
Æf     Implicit input. Obtain prime factors, sorted and with repetitions
  I    Consecutive differences
   ¬   Logical negate: zeros become 1, nonzeros become 0
    S  Sum. Implicit display
```
[Answer]
# J, ~~11~~ 10 bytes
Saved 1 byte thanks to [Jonah](https://codegolf.stackexchange.com/users/15469/jonah).
```
1#.1-~:@q:
```
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 6 bytes
```
Òg¹fg-
```
**Explanation**
```
Òg      # number of prime factors with duplicates
     -  # minus
  ¹fg   # number of prime factors without duplicates
```
[Try it online!](http://05ab1e.tryitonline.net/#code=w5JnwrlmZy0&input=OQ)
[Answer]
# Haskell, 65 bytes
```
(c%x)n|x>n=c|mod n x>0=c%(x+1)$n|y<-div n x=(c+0^mod y x)%x$y
0%2
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Ò¥_O
```
Port of [*@LuisMendo*'s MATL answer](https://codegolf.stackexchange.com/a/91422/52210).
[Try it online](https://tio.run/##yy9OTMpM/f//8KRDS@P9//@3AAA) or [verify the first 15 test cases](https://tio.run/##yy9OTMpM/W9o6upnr6Sga6egZO/3//CkQ0vj/f/r/AcA).
**Explanation:**
```
Ò       # Get all prime factors with duplicates from the (implicit) input
        # (automatically sorted from lowest to highest)
 ¥      # Get all deltas
  _     # Check if it's equal to 0 (0 becomes 1; everything else becomes 0)
   O    # Take the sum (and output implicitly)
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~5~~ 4 bytes
```
ΣẊ=p
```
[Try it online!](https://tio.run/##yygtzv6f@6ip8eGOxUam/88tfriry7bg/38A "Husk – Try It Online")
-1 byte from Dominic Van Essen.
[Answer]
# Pyth, 7 bytes
```
-lPQl{P
```
[Try it online.](https://pyth.herokuapp.com/?code=-lPQl%7BP&debug=0)
[Answer]
# C, 74 bytes
```
f(n,e,r,i){r=0;for(i=2;n>1;i++,r+=e?e-1:e)for(e=0;n%i<1;e++)n/=i;return r;}
```
[Ideone it!](http://ideone.com/C9U9SW)
[Answer]
# Python 2, ~~57~~ 56 bytes
```
f=lambda n,k=2:n/k and[f(n,k+1),(n/k%k<1)+f(n/k)][n%k<1]
```
*Thanks to @JonathanAllan for golfing off 1 byte!*
Test it on [Ideone](http://ideone.com/Y5aGTR).
[Answer]
# Python 2, ~~100~~ ~~99~~ ~~98~~ 96 bytes
```
n=input()
i=2
f=[]
while i<n:
 if n%i:i+=1
 else:n/=i;f+=i,
if-~n:f+=n,
print len(f)-len(set(f))
```
Most of the code is taken up by a golfed version of [this SO answer](https://stackoverflow.com/a/22808285), which stores the prime factors of the input in `f`. Then we simply use set manipulation to calculate the excess factors.
*Thanks to Leaky Nun for saving ~~1~~ 3 bytes!*
[Answer]
# [Brachylog](http://github.com/JCumin/Brachylog), 11 bytes
```
$p@b:la:-a+
```
[Try it online!](http://brachylog.tryitonline.net/#code=JHBAYjpsYTotYSs&input=MTI&args=Wg)
[Verify all testcases.](http://brachylog.tryitonline.net/#code=MTV5YjoxYTokQGF-QG53CiRwQGI6bGE6LWEr&input=) (The wrapper is longer than the function...)
```
$p@b:la:-a+
$p            prime factorization
  @b          group blocks of equal elements
    :la       length of each
       :-a    each minus 1
          +   sum
```
[Answer]
# [S.I.L.O.S](http://github.com/rjhunjhunwala/S.I.L.O.S), 113 bytes
```
readIO
t=2
lbla
e=0
GOTO b
lblc
i/t
e+1
lblb
m=i
m%t
n=1
n-m
if n c
d=e
d/d
e-d
r+e
A=i
A-1
t+1
if A a
printInt r
```
[Try it online!](http://silos.tryitonline.net/#code=cmVhZElPCnQ9MgpsYmxhCmU9MApHT1RPIGIKbGJsYwppL3QKZSsxCmxibGIKbT1pCm0ldApuPTEKbi1tCmlmIG4gYwpkPWUKZC9kCmUtZApyK2UKQT1pCkEtMQp0KzEKaWYgQSBhCnByaW50SW50IHI&input=&args=MTI)
A port of my [answer in C](https://codegolf.stackexchange.com/a/91429/48934).
[Answer]
## Javascript (ES6), ~~53~~ ~~51~~ 46 bytes
```
e=(n,i=2)=>i<n?n%i?e(n,i+1):e(n/=i,i)+!(n%i):0
```
*Saved 5 bytes thanks to Neil*
Example:
```
e=(n,i=2)=>i<n?n%i?e(n,i+1):e(n/=i,i)+!(n%i):0
// computing e(n) for n in [1, 30]
for(var n = 1, list = []; n <= 30; n++) {
  list.push(e(n));
}
console.log(list.join(','));
```
[Answer]
# Bash, 77 bytes
```
IFS=$'\n '
f=(`factor $1`)
g=(`uniq<<<"${f[*]}"`)
echo $((${#f[*]}-${#g[*]}))
```
Complete program, with input in `$1` and output to stdout.
We set `IFS` to begin with a newline, so that the expansion `"${f[*]}"` is newline-separated. We use arithmetic substitution to print the difference between the number of words in the factorisation with the result of filtering through `uniq`. The number itself is printed as a prefix by `factor`, but it is also present after filtering, so falls out in the subtraction.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
k äÎxÌ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=ayDkznjM&input=OA)
```
k äÎxÌ     :Implicit input of integer
k          :Prime factors
  ä        :Consecutive pairs reduced by
   Î       :  Signs of differences (0 or -1)
    x      :Sum of
     Ì     :  Signs of differences with -1 (0 -> 1 and -1 -> 0)
```
[Answer]
# [Factor](https://factorcode.org) + `math.primes.factors math.unicode`, 40 bytes
```
[ group-factors unzip Σ swap length - ]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=NYw_CsIwFMZ3T_FGBxvUSfQA4uJSnIpDjK-x2LzEvATRq7gEpB7HvbexkDp9P75_r08tVbA-9fpQ7vbbNRgZLsJL0siZnW8Mssg9Bsls1RhFapQ9I1zRE7bAeItIahyC8xjCY5hTgM1kOYdqMTsduxjqYtVPK9DeRlf8fyM9GwffN_BdOmiR9HBRwNjvzGCKzCll_QE)
```
               ! 12
group-factors  ! { { 2 2 } { 3 1 } }
unzip          ! { 2 3 } { 2 1 }
Σ              ! { 2 3 } 3
swap           ! 3 { 2 3 }
length         ! 3 2
-              ! 1
```
[Answer]
# [Pyt](https://github.com/mudkip201/pyt), 4 bytes
```
ḋ₋¬Ʃ
```
[Try it online!](https://tio.run/##K6gs@f//4Y7uR03dh9YcW/n/vwUA "Pyt – Try It Online")
Port of [Leaky Nun's Jelly answer](https://codegolf.stackexchange.com/questions/91420/excessive-integers/91424#91424)
[Answer]
# [Haskell](https://www.haskell.org/), 87 bytes
```
import Data.Numbers.Primes
import Data.List
x=(\x->length x-length(nub x)).primeFactors
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMElsSRRz680Nym1qFgvoCgzN7WYC1nKJ7O4hKvCViOmQtcuJzUvvSRDoUIXwtDIK01SqNDU1CsAaXNLTC7JLyr@n5uYmWcLFMkrUalQMDT6DwA "Haskell – Try It Online")
[Answer]
# [Kamilalisp](https://github.com/kspalaiologos/kamilalisp), 15 bytes
```
[-&[⍴] #0 ⊙]@⋔⌹
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m70qOzE3MycxJ7O4YMEyjZTUNIW0paUlaboW26N11aIf9W6JVVA2UHjUNTPW4VH3lEc9OyGyN0M0ubg0MvOtyosyS1Jz8hRiikuKrNLyi3ITSxSUUjUsNBVsFarTFCxqlTTxqTM0gCo0NACqhJi9YAGEBgA)
[Answer]
# [Nekomata](https://github.com/AlephAlpha/Nekomata), 3 bytes
```
ƒ←∑
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m70iLzU7PzexJHFZtJJurlLsgqWlJWm6FiuOTXrUNuFRx8QlxUnJxVDBBTeVDbmMuIy5TLhMucy4zLksuCy5DA24DA25DI24DI25DE24DE0hagE)
```
ƒ       Factor; returns a list of unique prime factors and a list of their exponents
 ←      Decrement the exponents
  ∑     Sum
```
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-rprime`, 31 bytes
```
->n{n.prime_division.sum{_2-1}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcnW0km5RQVFmbqpS7CI326WlJWm6Fvt17fKq8_TAwvEpmWWZxZn5eXrFpbnV8Ua6hrW1EFU3VRyD3N30UhOTM-JzMvNSFVLyuRQUChTcouMN9Ury4zNjuVLzUiBqF9xUNuQy4jLmMuEy5TLjMuey4LLkMjTgMjTkMjTiMjTmMjThMjSFqAUA)
[Answer]
# Python, (with sympy) 66 bytes
```
import sympy;lambda n:sum(x-1for x in sympy.factorint(n).values())
```
`sympy.factorint` returns a dictionary with factors as keys and their multiplicities as values, so the sum of the values is `Ω(n)` and the number of values is `ω(n)`, so the sum of the decremented values is what we want.
[Answer]
# CJam, 11 bytes
```
ri_mf,\mF,-
```
[Try it online!](http://cjam.tryitonline.net/#code=cmlfbWYsXG1GLC0&input=NA)
**Explanation**
```
ri_         Get an integer from input and duplicate it
   mf,      Get the number of prime factors (with repetition)
      \     Swap top 2 elements on the stack
       mF,  Get the number of prime factors (with exponents)
          - Subtract
```
[Answer]
**C, 158**
```
#define G(a,b) if(a)goto b
#define R return
f(n,i,j,o,w){if(!n)R 0;o=w=i=j=0;a:i+=2;b:if(n%i==0){++j;G(n/=i,b);}o+=!!j;w+=j;i+=(i==2);j=0;G(i*i<n,a);R w-o;}
```
In the start there is the goto instruction... even if this is more long
than yours it is more readable and right [if i not consider n too much big...]
one Language that has 10000 library functions is wrost than a 
Language that with few, 20 or 30 library functions can do all better [because
we can not remember all these functions]
```
#define F for
#define P printf
main(i,r)
{F(i=0; i<100; ++i)
   r=f(i,0,0,0,0),P("[%u|%u]",i,r);
 R  0;
}
/*
 158
 [0|0][1|0][2|0][3|0][4|1][5|0][6|0][7|0][8|2]
 [9|0][10|0][11|0][12|1][13|0][14|0][15|0][16|3]
 [17|0][18|0][19|0][20|1][21|0][22|0][23|0][24|2][25|1][26|0][27|0] [28|1]
 [29|0][30|0][31|0][32|4][33|0][34|0][35|0][36|1]
 [37|0][38|0][39|0][40|2][41|0]
 */
```
[Answer]
# GNU sed + coreutils, 55 bytes
(including +1 for `-r` flag)
```
s/^/factor /e
s/ ([^ ]+)(( \1)*)/\2/g
s/[^ ]//g
y/ /1/
```
Input in decimal, on stdin; output in unary, on stdout.
## Explanation
```
#!/bin/sed -rf
# factor the number
s/^/factor /e
# remove first of each number repeated 0 or more times
s/ ([^ ]+)(( \1)*)/\2/g
# count just the spaces
s/[^ ]//g
y/ /1/
```
[Answer]
# APL(NARS) 35 chars, 70 bytes
```
{⍵=1:0⋄k-⍨+/+/¨{w=⍵⊃v}¨⍳k←≢v←∪w←π⍵}
```
the function π find the factorization in prime of its argument;
there is few to say it seems clear, but for me does more operations (from factorization) than the minimum...the range of count characters is out golfing languages because it seems too much count, but less than not golfing languages... test:
```
  f←{⍵=1:0⋄k-⍨+/+/¨{w=⍵⊃v}¨⍳k←≢v←∪w←π⍵}
  f¨1..15
0 0 0 1 0 0 0 2 1 0 0 1 0 0 0 
```
[Answer]
# [Arturo](https://arturo-lang.io), 47 bytes
```
$=>[k:tally factors.prime&(∑values k)-size k]
```
[Try it!](http://arturo-lang.io/playground?KXg2zX)
]