Skip to content

Instantly share code, notes, and snippets.

@john212
Last active July 12, 2025 05:05
Show Gist options
  • Select an option

  • Save john212/81e9bf799f691f2ee31bfa9977c2d64f to your computer and use it in GitHub Desktop.

Select an option

Save john212/81e9bf799f691f2ee31bfa9977c2d64f to your computer and use it in GitHub Desktop.
Prime Number Finder
# Prime Number Finder
# Find all prime numbers betweeen 2 integers
# From a Grant Sanderson video
# Lockdown Math lesson 7 "What makes the natural log "natural"?
# Published May 8 2020
# https://www.3blue1brown.com/lessons/ldm-natural-logs
import numpy as np
import math
def get_primes(_n_min, _n_max):
result = []
for x in range(max(_n_min,2), _n_max):
has_factor = False
for p in range(2, int(np.sqrt(x)) +1):
if x % p == 0:
has_factor = True
break
if not has_factor:
result.append(x)
return result
print("Call get_primes(start,end)")
# Example
pnums = get_primes(70,90)
total = len(pnums)
print(total)
print(pnums)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment