JSFiddle - React, Tailwind, and code Playground

JavaScript

// https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
function pDistance(x, y, x1, y1, x2, y2) {

  var A = x - x1;
  var B = y - y1;
  var C = x2 - x1;
  var D = y2 - y1;

  var dot = A * C + B * D;
  var len_sq = C * C + D * D;
  var param = -1;
  if (len_sq != 0) //in case of 0 length line
      param = dot / len_sq;

  var xx, yy;

  if (param < 0) {
    xx = x1;
    yy = y1;
  }
  else if (param > 1) {
    xx = x2;
    yy = y2;
  }
  else {
    xx = x1 + param * C;
    yy = y1 + param * D;
  }

  var dx = x - xx;
  var dy = y - yy;
  return Math.sqrt(dx * dx + dy * dy);
}

const MAX = 10000000
const MIN_R = 40
const MAX_R = 80
const LIMIT_R = 50

let hits = 0


for (let i = 0; i< MAX; i++) {
	const r = Math.random() * (MAX_R - MIN_R) + MIN_R
  const a = Math.random() * Math.PI * 2
  const x = Math.cos(a) * r
  const y = Math.sin(a) * r

  const dist = pDistance(x, y, 0, 0, 0, MAX_R)
  if (dist <= LIMIT_R) {
  	hits++
    continue
  }

}

console.log((hits / MAX * 100) + "%")