How to find non reducible fractions more efficently(code keeps timing out)

I’m trying to find the non-reducible 0-1 fractions for a number passed as an argument in my function.
I was able to do this but my code keeps timing out for large numbers. Please help

function properFractions(n) {
  function gcd(a, b) {
    if (a == 0) return b;
    return gcd(b % a, a);
  }

  let result = 0;

  if (n === 1) {
    return result;
  } else if (n > 1) {
    for (let i = 1; i < n; i++) if (gcd(i, n) === 1) result++;
    return result;
  }
}