Skip to content

Instantly share code, notes, and snippets.

@gdemir
Created March 18, 2011 23:01
Show Gist options
  • Select an option

  • Save gdemir/877005 to your computer and use it in GitHub Desktop.

Select an option

Save gdemir/877005 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#-*-coding:utf-8-*-
# Find the sum of all the multiples of 3 or 5 below 1000.
print sum(i for i in range(1000) if i % 3 == 0 or i % 5 == 0)
#!/usr/bin/python
#-*-coding:utf-8-*-
# What is the 10001st prime number?
def prime_n(max):
primes = []
n = 2
while True:
prime = True
for i in range(2, n):
if n % i == 0: prime = False; break
if prime: primes.append(n)
if len(primes) == max: return primes
n = n + 1
print prime_n(10001)[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment