diff options
author | mjfernez <mjfernez@gmail.com> | 2020-02-03 23:04:10 -0500 |
---|---|---|
committer | mjfernez <mjfernez@gmail.com> | 2020-02-03 23:04:10 -0500 |
commit | 8e431d287c0e89041506da4c4da57e3e3d657d72 (patch) | |
tree | b6cd296fbdd75d1421fe84a82cf3eec859407dcb /10001prime.py.orig | |
parent | e6a7399134b3dc08f9e6e9c9c74e39ac449b8538 (diff) | |
download | Project_Euler_Solutions-8e431d287c0e89041506da4c4da57e3e3d657d72.tar.gz |
cleanup, added c translations for some
Diffstat (limited to '10001prime.py.orig')
-rw-r--r-- | 10001prime.py.orig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/10001prime.py.orig b/10001prime.py.orig new file mode 100644 index 0000000..ecaa8cd --- /dev/null +++ b/10001prime.py.orig @@ -0,0 +1,30 @@ +import PIL, math + +#Problem 7 - 10,001st prime + +#returns a list of every prime up to a certain number +def listprimes(number): + primes = [] + if (number <=1): + return [1] + a = [1] * number + a[0]=0 + a[1]=0#1 and 0 are not prime + ##Sieve of eratosthenes + for i in range(2,int(math.ceil(math.sqrt(number)))): + if(a[i]==1): + j = i**2 #cross out all the multiples of i, starting with its square + while(j < number): + a[j] = 0 + j+=i + + for k in range(2, number): + #is prime + if(a[k]==1): + primes.append(k) + return primes + +out_list = listprimes(1000000) +#print(out_list) +#return 10,001th prime factor +print(out_list[10000]) |