[Question]
  [
# Background
Euler's [totient](https://en.wikipedia.org/wiki/Euler%27s_totient_function)
function `œÜ(n)` is defined as the number of whole numbers less than or equal to `n` that are relatively prime to `n`,
that is, the number of possible values of `x` in `0 < x <= n` for which
`gcd(n, x) == 1`.
We've had
[a](https://codegolf.stackexchange.com/questions/83046/golf-the-repeated-totient-function)
[few](https://codegolf.stackexchange.com/questions/63710/calculate-phi-not-pi) [totient](https://codegolf.stackexchange.com/questions/26739/super-speedy-totient-function)-[related](https://codegolf.stackexchange.com/questions/79082/draw-a-phi-triangle) [challenges](https://codegolf.stackexchange.com/questions/67773/co-primality-and-the-number-pi)
before, but never one which is just calculating it.
The mapping of the totient function onto the whole numbers is [OEIS A000010](http://oeis.org/A000010).
# Challenge
Given an integer `n > 0`, calculate `œÜ(n)`.
You may take input through
command-line arguments,
standard input,
function arguments,
or anything else reasonable.
You may give output through
standard output,
return values,
or anything else reasonable.
Anonymous functions are acceptable.
You may assume that the input will not overflow your natural method of storing integers, e.g. `int` in C, but you **must** support inputs up to 255.
**If your language has a built-in totient function, you may not use it.**
# Examples
```
œÜ(1) => 1
œÜ(2) => 1
œÜ(3) => 2
œÜ(8) => 4
œÜ(9) => 6
œÜ(26) => 12
œÜ(44) => 20
œÜ(105) => 48
```
Shortest answer in bytes wins. If your language uses an encoding other than UTF-8, mention it in your answer. 
  
[Answer]
## Mathematica, ~~27~~ 22 bytes
```
Range@#~GCD~#~Count~1&
```
An unnamed function that takes and returns an integer.
Not much to explain here, except that `@` is prefix notation for function calls and `~...~` is (left-associative) infix notation, so the above is the same as:
```
Count[GCD[Range[#], #], 1] &
```
[Answer]
# J, 9 bytes
```
(-~:)&.q:
```
This is based on the Jsoftware's [essay](http://code.jsoftware.com/wiki/Essays/Totient_Function) on totient functions.
Given *n* = *p*1*e*1 ‚àô *p*2*e*2 ‚àô‚àô‚àô *p**k**e**k* where *p**k* is a prime factor of *n*, the totient function œÜ(*n*) = œÜ(*p*1*e*1) ‚àô œÜ(*p*2*e*2) ‚àô‚àô‚àô œÜ(*p**k**e**k*) = (*p*1 - 1) *p*1*e*1 - 1 ‚àô (*p*2 - 1) *p*2*e*2 - 1 ‚àô‚àô‚àô (*p**k* - 1) *p**k**e**k* - 1.
## Usage
```
   f =: (-~:)&.q:
   (,.f"0) 1 2 3 8 9 26 44 105
  1  1
  2  1
  3  2
  8  4
  9  6
 26 12
 44 20
105 48
   f 12345
6576
```
## Explanation
```
(-~:)&.q:  Input: integer n
       q:  Prime decomposition. Get the prime factors whose product is n
(   )&     Operate on them
  ~:         Nub-sieve. Create a mask where 1 is the first occurrence
             of a unique value and 0 elsewhere
 -           Subtract elementwise between the prime factors and the mask
     &.q:  Perform the inverse of prime decomposition (Product of the values)
```
[Answer]
# MATL, 7 bytes
```
t:Zd1=s
```
You can [TryItOnline](http://matl.tryitonline.net/#code=dDpaZDE9cw&input=MTA1). Simplest idea, make a vector 1 to N, and taken gcd of each element with N (`Zd` does gcd). Then, find which elements are equal to 1, and sum the vector to get the answer.
[Answer]
## Haskell, 28 bytes
```
f n=sum[1|1<-gcd n<$>[1..n]]
```
Uses Haskell's [pattern matching of constants](https://codegolf.stackexchange.com/a/83103/20260). The tricks here are fairly standard for golfing, but I'll explain to a general audience.
The expression `gcd n<$>[1..n]` maps `gcd n` onto `[1..n]`. In other words, it computes the `gcd` with `n` of each number from `1` to `n`:
```
[gcd n i|i<-[1..n]]
```
From here, the desired output is the number of `1` entries, but Haskell lacks a `count` function. The idiomatic way to `filter` to keep only `1`'s, and take the resulting `length`, which is much is too long for golfing.
Instead, the `filter` is simulated by a list comprehension `[1|1<-l]` with the resulting list `l`. Usually, list comprehensions bind values onto variable like in `[x*x|x<-l]`, but Haskell allows a pattern to be matched against, in this case the constant `1`.
So, `[1|1<-l]` generating a `1` on each match of `1`, effectively extracting just the `1`'s of the original list. Calling `sum` on it gives its length.
[Answer]
## Python 2, 44 bytes
```
f=lambda n,d=1:d/n or-f(d)*(n%d<1)-~f(n,d+1)
```
Less golfed:
```
f=lambda n:n-sum(f(d)for d in range(1,n)if n%d<1)
```
Uses the formula that the Euler totients of the divisors of `n` have a sum of `n`:
[![enter image description here](https://i.stack.imgur.com/k7xiE.png)](https://i.stack.imgur.com/k7xiE.png)
The value of `œï(n)` can then be recursively computed as `n` minus the sum over nontrivial divisors. Effectively, this is doing [M√∂bius inversion](https://en.wikipedia.org/wiki/M%C3%B6bius_inversion_formula) on the identity function. I used the same method in a [golf to compute the M√∂bius function](https://codegolf.stackexchange.com/a/70024/20260).
Thanks to Dennis for saving 1 byte with a better base case, spreading the initial value of `+n` into `+1` for each of the `n` loops, done as `-~`.
[Answer]
# Jelly, 4 bytes
```
Rgƒã1
```
[Try it online!](http://jelly.tryitonline.net/#code=UmfEizE&input=&args=NDQ)
### Explanation
```
Rgƒã1   Main monadic chain. Argument: z
R      Yield [1 2 3 .. z].
 g     gcd (of each) (with z).
  ƒã1   Count the number of occurrences of 1.
```
## With built-in
```
√Ü·π™
```
[Try it online!](http://jelly.tryitonline.net/#code=w4bhuao&input=&args=NDQ)
### Explanation
```
√Ü·π™   Main monadic chain. Argument: z
√Ü·π™   Totient of z.
```
[Answer]
# Regex (ECMAScript), 131 bytes
*At least -12 bytes thanks to Deadcode (in chat)*
```
(?=((xx+)(?=\2+$)|x+)+)(?=((x*?)(?=\1*$)(?=(\4xx+?)(\5*(?!(xx+)\7+$)\5)?$)(?=((x*)(?=\5\9*$)x)(\8*)$)x*(?=(?=\5$)\1|\5\10)x)+)\10|x
```
[Try it online!](https://tio.run/##TY5BT4MwGIb/CiNL@D4YbCxj6rBw8rCLBz2Kh4Z1pVoKKXXDib8dO5Il3t6@z/vk6wc90a7UojVh14oD03WjPtn3qIliZ@eF8ae@BbiQbOmPkBOAvg/QhmIdzHGweXrZ2s@nOvbnU1Fs7NBWReJDPpus4s4qRYL5/KZMRlI8WKe303sfbfCv8NrbcTxYHK8stXq8GvrRX14wMs2r0UJxwKiTomSwXYQbxPRcCckAJNGMHqRQDBBnRH1JiT@cyKhrpTDghR6m4gigCI8kU9xUmK2HQXTP9BkEaanu2F4Z4G@rd8QbYP@ByuI83l0xmko3Z3evTlSKg6Op4mznuIFMj42GVDwSloogQHuwJm7vRpq1jBoQGNXUlBVoxLJRXSNZJBsOYuF4YeYtnNpev30v/R3jcJ1s/wA)
Output is the length of the match.
ECMAScript regexes make it extremely hard to count anything. Any backref defined outside a loop will be constant during the loop, any backref defined inside a loop will be reset when looping. Thus, the only way to carry state across loop iterations is using the current match position. That‚Äôs a single integer, and it can only decrease (well, the position increases, but the length of the tail decreases, and that‚Äôs what we can do math to).
Given those restrictions, simply counting coprime numbers seems impossible. Instead, we use [Euler‚Äôs formula](https://en.wikipedia.org/wiki/Euler%27s_totient_function#Euler%27s_product_formula) to compute the totient.
Here‚Äôs how it looks like in pseudocode:
```
N = input
Z = largest prime factor of N
P = 0
do:
   P = smallest number > P that‚Äôs a prime factor of N
   N = N - (N / P)
while P != Z
return N
```
There are two dubious things about this.
First, we don‚Äôt save the input, only the current product, so how can we get to the prime factors of the input? The trick is that (N - (N / P)) has the same prime factors > P as N. It may gain new prime factors < P, but we ignore those anyway. Note that this only works because we iterate over the prime factors from smallest to greatest, going the other way would fail.
Second, we have to remember two numbers across loop iterations (P and N, Z doesn‚Äôt count since it‚Äôs constant), and I just said that was impossible! Thankfully, we can swizzle those two numbers in a single one. Note that, at the start of the loop, N will always be a multiple of Z, while P will always be less than Z. Thus, we can just remember N + P, and extract P with a modulo.
Here‚Äôs the slightly more detailed pseudo-code:
```
N = input
Z = largest prime factor of N
do:
   P = N % Z
   N = N - P
   P = smallest number > P that‚Äôs a prime factor of N
   N = N - (N / P) + P
while P != Z
return N - Z
```
And here‚Äôs the commented regex:
```
# \1 = largest prime factor of N
# Computed by repeatedly dividing N by its smallest factor
(?= ( (xx+) (?=\2+$) | x+ )+ )
(?=
        # Main loop!
        (
                # \4 = N % \1, N -= \4
                (x*?) (?=\1*$)
                # \5 = next prime factor of N
                (?= (\4xx+?) (\5* (?!(xx+)\7+$) \5)? $ )
                # \8 = N / \5, \9 = \8 - 1, \10 = N - \8
                (?= ((x*) (?=\5\9*$) x) (\8*) $ )
                x*
                (?=
                        # if \5 = \1, break.
                        (?=\5$) \1
                |
                        # else, N = (\5 - 1) + (N - B)
                        \5\10
                )
                x
        )+
) \10
```
And as a bonus‚Ä¶
## Regex `üêù` (ECMAScript 2018, number of matches), 23 bytes
```
x(?<!^\1*(?=\1*$)(x+x))
```
[Try it online!](https://tio.run/##DY3BCoJAFEV/5SWB76U@ctGmMmnRD9TSDIdpGC1TGYcawX@32dwDhwP3Jb5ilKYZbNL1T7UYyOCq9MUNeLOm6TQb8asWh/lx9binG8wzv2tCFzmipeKxbaTCNE5SiiHUIR0KZj4bIybcbYnfahqRSv6IAR1kJ5B9N/at4rbXXkQQ7iH0wMAFbNSghEVHPreyRkMwz1CUxK3qtK394x8)
Output is the number of matches. ECMAScript 2018 introduces variable-length look-behind (evaluated right-to-left), which makes it possible to simply count all numbers coprime with the input.
It turns out this is independently the same method used by [Leaky Nun's Retina solution](https://codegolf.stackexchange.com/a/83550/17216), and the regex is even the same length ([and interchangeable](https://tio.run/##DcrBCoJAEIDhV5kk2JnUIQ9dKpMOvUAd1WixZbVMZXepFXx38/TDx/@SX2kr0wwu7vqnmg2kcFX64ge8OdN0mo38PWbMVuh9SEWyWWN2TO9FEhL5@cG2bSqFSRQnFIHQgg45M5@NkSPutsRvNVqkkj9yQA/pCaq@s32ruO31AiGIPYglGPiAjRqUdOhp2V1VoyGYJshL4lZ12tVE8x8)). I'm leaving it here because it may be of interest that this method works in ECMAScript 2018 (and not just .NET).
```
                        # Implicitly iterate from the input to 0
x                       # Don‚Äôt match 0
 (?<!                 ) # Match iff there is no...
                 (x+x)  # integer >= 2...
         (?=\1*$)       # that divides the current number...
     ^\1*               # and also divides the input
```
[Answer]
## Pyke, 5 bytes
```
m.H1/
```
[Try it here!](http://pyke.catbus.co.uk/?code=m.H1%2F&input=105&warnings=0)
```
count(map(gcd, range(input)), 1)
```
[Answer]
# J, 11 bytes
```
+/@(1=+.)i.
```
## Usage
```
>> f =: +/@(1=+.)i.
>> f 44
<< 20
```
where `>>` is STDIN and `<<` is STDOUT.
## Explanation
```
+/ @ ( 1 = +. ) i.
               ‚îÇ
   ‚îå‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚î¥‚îê
 +/@(1=+.)      i.
   ‚îÇ
 ‚îå‚îÄ‚îº‚îÄ‚îÄ‚îê
+/ @ 1=+.
    ‚îå‚îÄ‚îº‚îÄ‚îê
    1 = +.
>> (i.) 44            NB. generate range
<< 0 1 2 3 4 ... 43
>> (+.i.) 44          NB. calculate gcd of each with input
<< 44 1 2 1 4 ... 1
>> ((1=+.)i.) 44      NB. then test if each is one (1 if yes, 0 if no)
<< 0 1 0 1 0 ... 1
>> (+/@(1=+.)i.) 44   NB. sum of all the tests
<< 20
```
[Answer]
# Python >=3.5, ~~76~~ ~~64~~ 58 bytes
*Thanks to LeakyNun for golfing off 12 (!) bytes.*
*Thanks to Sp3000 for golfing off 6 bytes.*
```
import math
lambda n:sum(math.gcd(n,x)<2for x in range(n))
```
I love how readable Python is. This makes sense, even through the golfedness.
[Answer]
# Ruby, 32 bytes
```
->n{(1..n).count{|i|i.gcd(n)<2}}
```
a lambda that takes an integer n, and returns the counts of how many integers in the range (1..n) are coprime with n.
[Answer]
# [Perl 6](http://perl6.org), ~~¬†26 24¬†~~ 22 bytes
```
~~{[+] (^$^n Xgcd $n) X== 1}
{+grep 2>\*,(^$\_ Xgcd$\_)}~~
{[+] 2 X>(^$_ Xgcd$_)}
```
### Explanation:
```
{
  [+] # reduce using &infix:<+>
    2
    X[>] # crossed compared using &infix:¬´>¬ª
    (
      ^$_    # up to the input ( excludes input )
      X[gcd] # crossed using &infix:<gcd>
      $_     # the input
    )
}
```
### Example:
```
#! /usr/bin/env perl6
use v6.c;
my &œÜ = {[+] 2 X>(^$_ Xgcd$_)};
say œÜ(1) # 1
say œÜ(2) # 1
say œÜ(3) # 2
say œÜ(8) # 4
say œÜ(9) # 6
say œÜ(26) # 12
say œÜ(44) # 20
say œÜ(105) # 48
say œÜ 12345 # 6576
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 25 bytes
```
:{:1e.$pdL,?$pd:LcCdC}fl.
```
### Explanation
Brachylog has no GCD built-in yet, so we check that the two numbers have no prime factors in common.
* Main predicate:
```
:{...}fl.             Find all variables which satisfy predicate 1 when given to it as
                      output and with Input as input.
                      Unify the Output with the length of the resulting list
```
* Predicate 1:
```
:1e.                  Unify Output with a number between Input and 1
    $pdL              L is the list of prime factors of Output with no duplicates
        ,
         ?$pd:LcC     C is the concatenation of the list of prime factors of Input with
                      no duplicates and of L
                 dC   C with duplicates removed is still C
```
[Answer]
# Python 2, 57 bytes
```
f=lambda n,k=1,m=1:n*(k>n)or f(n-(n%k<m%k)*n/k,k+1,m*k*k)
```
Test it on [Ideone](http://ideone.com/RhBbpO).
### Background
By [Euler's product formula](https://en.wikipedia.org/wiki/Euler%27s_totient_function#Euler.27s_product_formula),
![Euler's product formula](https://i.stack.imgur.com/0Adtc.png)
where **φ** denotes Euler's totient function and **p** varies only over prime numbers.
To identify primes, we use a corollary of [Wilson's theorem](https://en.wikipedia.org/wiki/Wilson%27s_theorem):
![corollary of Wilson's theorem](https://i.stack.imgur.com/ordYr.png)
### How it works
At all times, the variable **m** will be equal to the square of the factorial of **k - 1**. In fact, we named arguments default to **k = 1** and **m = 0!2 = 1**.
As long as **k ≤ n**, `n*(k>n)` evaluates to **0** and the code following `or` gets executed.
Recall that `m%k` will yield **1** if **m** is prime and **0** if not. This means that `x%k<m%k` will yield **True** if and only if both **k** is a prime number and **x** is divisible by **k**.
In this case, `(n%k<m%k)*n/k` yields **n / k**, and subtracting it from **n** replaces its previous value with **n(1 - 1/k)**, as in Euler's product formula. Otherwise, `(n%k<m%k)*n/k` yields **0** and **n** remains unchanged.
After computing the above, we increment **k** and multiply **m** by the "old" value of **k2**, thus maintaining the desired relation between **k** and **m**, then call **f** recursively with the updated arguments.
Once **k** exceeds **n**, `n*(k>n)` evaluates to **n**, which is returned by the function.
[Answer]
# [Python 2](https://docs.python.org/2/), 44 bytes
```
lambda n:sum(k/n*k%n>n-2for k in range(n*n))
```
This uses the same method to identify coprimes as [my answer to ‚ÄúCoprimes up to N‚Äù](https://codegolf.stackexchange.com/a/104681/12012).
[Try it online!](https://tio.run/##FcyxDoIwGEXhWZ/iLg2F/EYpaJQEnsSlplZJ5UIqDj59tdvJN5zluz5nmuTR45pedro5C3bvz6TDnlVQHLgzfo4IGIlo@bhrVizLlJEZdS0wgkZwFlz@fRK0raA@HMtuu1niyBWFahz6Acq4AgqaAq/z5gc "Python 2 ‚Äì Try It Online")
[Answer]
# Julia 1.x, 22 bytes
```
!n=sum(gcd.(1:n,n).<2)
```
This is the same as the old solution, but using newer features of the language, as the original solution dates back to something like Julia 0.4. This solution uses function broadcasting to achieve the result more efficiently.
---
# Julia, 25 bytes
```
!n=sum(i->gcd(i,n)<2,1:n)
```
It's simple - the `sum` function allows you to give it a function to apply before summing - basically the equivalent of running `map` and then `sum`. This directly counts the number of relatively prime numbers less than `n`.
[Answer]
# Pyth, 6 bytes
```
smq1iQ
```
[Try it online!](http://pyth.herokuapp.com/?code=smq1iQ&input=44&debug=0)
```
/iLQQ1
```
[Try it online!](http://pyth.herokuapp.com/?code=%2FiLQQ1&input=44&debug=0)
## Explanation
```
smq1iQ     input as Q
smq1iQdQ   implicitly fill variables
 m     Q   for d in [0 1 2 3 .. Q-1]:
    iQd        gcd of Q and d
  q1           equals 1? (1 if yes, 0 if no)
s          sum of the results
/iLQQ1     input as Q
 iLQQ      gcd of each in [0 1 2 3 .. Q-1] with Q
/    1     count the number of occurrences of 1
```
[Answer]
## PowerShell v2+, 72 bytes
```
param($n)1..$n|%{$a=$_;$b=$n;while($b){$a,$b=$b,($a%$b)};$o+=!($a-1)};$o
```
PowerShell doesn't have a GCD function available to it, so I had to roll my own.
This takes input `$n`, then ranges from `1` to `$n` and pipes those into a loop `|%{...}`. Each iteration we set two helper variables `$a` and `$b` and then execute a GCD `while` loop. Each iteration we're checking that `$b` is still non-zero, and then saving `$a%$b` to `$b` and the previous value of `$b` to `$a` for the next loop. We then accumulate whether `$a` is equal to `1` in our output variable `$o`. Once the for loop is done, we place `$o` on the pipeline and output is implicit.
As an example of how the `while` loop works, consider `$n=20` and we're on `$_=8`. The first check has `$b=20`, so we enter the loop. We first calculate `$a%$b` or `8%20 = 8`, which gets set to `$b` at the same time that `20` gets set to `$a`. Check `8=0`, and we enter the second iteration. We then calculate `20%8 = 4` and set that to `$b`, then set `$a` to `8`. Check `4=0`, and we enter the third iteration. We calculate `8%4 = 0` and set that to `$b`, then set `$a` to `4`. Check `0=0` and we exit the loop, so the *GCD(8,20)* is `$a = 4`. Thus, `!($a-1) = !(4-1) = !(3) = 0` so `$o += 0` and we don't count that one.
[Answer]
# Factor, 50 bytes
```
[ dup iota swap '[ _ gcd nip 1 = ] filter length ]
```
Makes a range (*iota*) **n**, and *curries* **n** into a function which gets **gcd x n** for all values of **0 <= x <= n**, tests if the result is **1**. *Filter* the original range on whether the result of **gcd x n** was **1**, and take its *length*.
[Answer]
# Japt `-mx`, ~~7~~ 5 bytes
```
yN ¬•1
```
[Run it online](https://ethproductions.github.io/japt/?v=1.4.6&code=eU4gpTE=&input=MTA1Ci1teA==)
-2 bytes thanks to [Shaggy](https://codegolf.stackexchange.com/users/58974/shaggy)
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~67~~ 65 bytes
```
f(x,a,b,y,z){for(z=y=x;a=y--;z-=b>1)for(b=x;a^=b^=a^=b%=a;);x=z;}
```
[Try it online!](https://tio.run/##bcyxCsIwEIDh3ccoFO4gAaMVlON8klJIIpEORikdkpQ@e0pmb/mHb/i9fntfa4CkrHIqq4Jb@C5QOHMiy1lrKprd02Bj13BiN3Frz5aQEhfa68fOEXA7/ZY5rgG6/jXGTgUwiPSHFwmvEt4lfIjPQdJBVHO@Nd7rAQ "C (gcc) ‚Äì Try It Online")
Edit: Removed temp variable.
Edit2: -1 thanks to [@HowChen](https://codegolf.stackexchange.com/questions/77270/greatest-common-divisor/152046#152046)
Slightly less golfed
```
f(x,a,b,y,z){
  // counts y NOT coprime with x and subtract
  for(z=y=x;a=y--;z-=b>1)
    // compute GCD
    for(b=x;a^=b^=a^=b%=a;);
  x=z;
}
```
[Answer]
# Retina, ~~36~~ 29 bytes
7 bytes thanks to Martin Ender.
```
.+
$*
(?!(11+)\1*$(?<=^\1+)).
```
[Try it online!](http://retina.tryitonline.net/#code=LisKJCoKKD8hKDExKylcMSokKD88PV5cMSspKS4&input=MTA1)
## Explanation
There are two stages (commands).
### First stage
```
.+
$*
```
It is a simple regex substitution, converting the input to that many ones.
For example, `5` would be converted to `11111`.
### Second stage
```
(?!(11+)\1*$(?<=^\1+)).
```
This regex tries to match the positions which satisfy the condition (co-prime with input), and then return the number of matches.
[Answer]
## 05AB1E, 7 bytes
```
Lvy¬π¬øi¬º
```
**Explained**
```
Lv        # for each x in range(1,n)
  y¬π¬ø     # GCD(x,n)
     i¬º   # if true (1), increase counter
          # implicitly display counter
```
[Try it online](http://05ab1e.tryitonline.net/#code=THZ5wrnCv2nCvA&input=MTA1)
[Answer]
**Common Lisp, 58 bytes**
```
(defun o(x)(loop for i from 1 to x if (=(gcd x i)1)sum 1))
```
This is a simple loop which counts up 1 to the given n and increments the sum if gcd = 1. I use the function name o since t is the true boolean value. Not nearly the shortest but fairly simple.
[Answer]
# MATLAB / Octave, 21 bytes
```
@(n)sum(gcd(n,1:n)<2)
```
Creates an anonymous function named `ans` which can be called with the integer `n` as the only input: `ans(n)`
[**Online Demo**](http://ideone.com/yghvhv)
[Answer]
# APL, 7 bytes
```
+/1=‚ä¢‚à®‚ç≥
```
This is a monadic function train that takes an integer on the right. The approach here is the obvious one: sum (`+/`) the number of times the GCD of the input and the numbers from 1 to the input (`‚ä¢‚à®‚ç≥`) is equal to 1 (`1=`).
[Try it here](http://tryapl.org/?a=f%20%u2190%20+/1%3D%u22A2%u2228%u2373%20%u22C4%20f%20105&run)
[Answer]
# Haskell, ~~31~~ 30 bytes
```
\n->sum[1|x<-[1..n],gcd n x<2]
```
*1 byte saved, thanks to @Damien.*
Selects values with gcd = 1, maps each to 1, then takes the sum. 
[Answer]
# JavaScript (ES6), 53 bytes
```
f=(n,k=n)=>k--&&(C=(a,b)=>b?C(b,a%b):a<2)(n,k)+f(n,k)
```
[Try it online!](https://tio.run/##dc3BDsIgDIDhu0/BxaWN4AbiMo3oYU8CcxjdAsYZXx@HkYMknprma/rf9EtP3eN6fzLnz30IVoGjg3KojgNjRQGtAk3NvJpTC4bqpcG9PgiMZ7iynxE67yY/9uvRX8ACRySElCXhi18Q/2CTQGTQJJAZ7BLUeaOOEhv5Lym/IqpMeLWdKVaa8AY "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [Brachylog v2](https://github.com/JCumin/Brachylog), 16 bytes
```
{>‚Ñï‚âú;?·∏ãÀ¢{‚äá·µõ!}ƒñ}·∂ú
```
[Try it online!](https://tio.run/##AVgAp/9icmFjaHlsb2cy/3t3IiAtPiAidz/ihrDigoLhuol94bWQ/3s@4oSV4omcOz/huIvLonviiofhtZshfcSWfeG2nP//WzEsMiwzLDgsOSwyNiw0NCwxMDVd "Brachylog ‚Äì Try It Online")
```
{             }·∂ú    Count the number of possible ways that:
  ‚Ñï‚âú                some non-negative integer
 >                  less than the input
    ;?              and the input
      ·∏ãÀ¢            have prime factorizations
        {‚äá·µõ!}       the largest shared subset of which
             ƒñ      is empty.
```
# [Brachylog v2](https://github.com/JCumin/Brachylog), 16 bytes
```
‚ü®‚ü¶‚ÇÖzg‚ü©{·∏ãÀ¢‚äá·µõ!ƒñ}À¢l
```
[Try it online!](https://tio.run/##AVsApP9icmFjaHlsb2cy/3t3IiAtPiAidz/ihrDigoLhuol94bWQ/@KfqOKfpuKChXpn4p@pe@G4i8ui4oqH4bWbIcSWfcuibP//WzEsMiwzLDgsOSwyNiw0NCwxMDVd "Brachylog ‚Äì Try It Online")
```
   z                Cycling zip
 ‚ü¶‚ÇÖ                 the range from 0 to one less than the input
‚ü®   g‚ü©              with a list containing only the input.
      {      }À¢     Map where possible over the pairs:
       ·∏ãÀ¢           the prime factorizations'
         ‚äá·µõ!        largest shared subset
            ƒñ       is empty.
               l    For how many pairs did it succeed?
```
A nuance that my explanations fail to capture is that `·∏ã` fails given an input of 1, so if `·∏ãÀ¢` is given a list containing 1, the 1 is essentially discarded and ignored--so the `‚äá·µõ!` (which is really "find any common subset, then discard all of this predicate's choice points", hence the braces in the first solution) of the remaining single number is its entire prime factorization, decidedly not empty, unless the list was nothing but 1s in which case everything is empty.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 7 bytes
```
·πÅo=1‚åã¬π·∏£
```
[Try it online!](https://tio.run/##yygtzv6f@6ip8eGOxYYGBv8f7mzMtzV81NN9aCdQ5P9/AA "Husk ‚Äì Try It Online")
```
·πÅo=1‚åã¬π·∏£
·πÅ     ·∏£     # sum of function applied to 1..input
 o          # join 2 functions:
    ‚åã¬π      # greatest common divisor with input
  =1        # equals 1
```
]