diff options
author | mjf <mjf@localhost.localdomain> | 2020-02-04 12:11:30 -0500 |
---|---|---|
committer | mjf <mjf@localhost.localdomain> | 2020-02-04 12:11:30 -0500 |
commit | 6aa02212cd6dfbb492fa1f70b60a4fe3d48892e5 (patch) | |
tree | 1b655714c9709ee8fce333fcb6a6be3f5533b2d3 /largestprime.py | |
parent | 8e431d287c0e89041506da4c4da57e3e3d657d72 (diff) | |
download | Project_Euler_Solutions-6aa02212cd6dfbb492fa1f70b60a4fe3d48892e5.tar.gz |
cleanup and added more c examples:
Diffstat (limited to 'largestprime.py')
-rw-r--r-- | largestprime.py | 43 |
1 files changed, 1 insertions, 42 deletions
diff --git a/largestprime.py b/largestprime.py index fa53dc5..387de01 100644 --- a/largestprime.py +++ b/largestprime.py @@ -1,47 +1,6 @@ import PIL import math -import numpy as np # Problem 3 Largest Prime Factor - -###INEFFICIENT METHODS### -# def isPrime(number): -# if (number <=1): -# return False -# for i in range(2,number): -# if(number%i==0): -# return False -# return True - -# def prime_factors(number): -#primes = [] -# for i in range(number, 2, -1): -# if(number%i==0): -# if (isPrime(i)): -# return i -# return primes - - -def prime_factors(number): - primes = [] - if (number <= 1): - return [1] - a = np.ones(number) - a[0] = 0 - a[1] = 0 # not prime - for i in range(2, int(math.ceil(math.sqrt(number)))): - if(a[i] == 1): - j = i**2 # cross out all the multiples - while(j < number): - a[j] = False - j += i - - for k in range(2, number): - # is prime is a factor - if(a[k] == 1) and (number % k == 0): - primes.append(k) - return primes - - def lpf(number): factor = 2 while (number > factor): @@ -54,4 +13,4 @@ def lpf(number): out = lpf(600851475143) -print out +print(out) |