import math


def poisson(lam, n, highest_k):
  """Generates probability of n or more cognates assuming Poisson distribution.

  Args:
    lam: The mean of the Poisson
    n: true cognates
    highest_k: bottom of range to generate
  Returns: area under the Poisson distribution for k >= n, or 0 if underflow.
  """
  try:
    p = 0
    loglam = math.log(lam)
    for k in range(n, highest_k):
      p += math.e ** (loglam * k - lam - math.log(math.factorial(k)))
    return p
  except ValueError:
    return 0