Skip to content

Instantly share code, notes, and snippets.

@kimihito
Created November 21, 2012 09:23
Show Gist options
  • Select an option

  • Save kimihito/4123955 to your computer and use it in GitHub Desktop.

Select an option

Save kimihito/4123955 to your computer and use it in GitHub Desktop.
return list of primes
#!/usr/bin/env python
# coding: utf-8
from math import *
def prime(val):
primes = []
for i in range(2,val):
isPrime = True
for j in range(2, int(floor(sqrt(i))) + 1):
if i % j == 0:
isPrime = False
if isPrime:
primes.append(i)
return primes
print prime(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment