Skip to main content
edited tags
Link
Toby Speight
  • 81.7k
  • 14
  • 101
  • 308
deleted 702 characters in body
Source Link
Graipher
  • 41.1k
  • 7
  • 69
  • 133

#prime factors - ex.3

primes = [] for possibleprime in range (2,100000,1): isPrime = True for num in range(2, possibleprime, 1): if possibleprime % num == 0: isPrime = False

#prime factors - ex.3

primes = []
for possibleprime in range (2,100000,1):
    isPrime = True
    for num in range(2, possibleprime, 1):
        if possibleprime % num == 0:
            isPrime = False
      
    if isPrime:
        primes.append(possibleprime)
                 
        
#print(primes)

def prime(n):
    prime_factors = []
    n = int(n)
    for x in primes:
        if n % x == 0:
            prime_factors.append(x)
    return prime_factors
            
            
# n = 13195 
# print(prime(n))

n = 600851475143
print(prime(n))

    

#print(primes)

def prime(n): prime_factors = [] n = int(n) for x in primes: if n % x == 0: prime_factors.append(x) return prime_factors

n = 13195

print(prime(n))

n = 600851475143 print(prime(n))

#prime factors - ex.3

primes = []
for possibleprime in range (2,100000,1):
    isPrime = True
    for num in range(2, possibleprime, 1):
        if possibleprime % num == 0:
            isPrime = False
      
    if isPrime:
        primes.append(possibleprime)
                 
        
#print(primes)

def prime(n):
    prime_factors = []
    n = int(n)
    for x in primes:
        if n % x == 0:
            prime_factors.append(x)
    return prime_factors
            
            
# n = 13195 
# print(prime(n))

n = 600851475143
print(prime(n))

#prime factors - ex.3

primes = [] for possibleprime in range (2,100000,1): isPrime = True for num in range(2, possibleprime, 1): if possibleprime % num == 0: isPrime = False

if isPrime:
    primes.append(possibleprime)
             
    

#print(primes)

def prime(n): prime_factors = [] n = int(n) for x in primes: if n % x == 0: prime_factors.append(x) return prime_factors

n = 13195

print(prime(n))

n = 600851475143 print(prime(n))

#prime factors - ex.3

primes = []
for possibleprime in range (2,100000,1):
    isPrime = True
    for num in range(2, possibleprime, 1):
        if possibleprime % num == 0:
            isPrime = False
      
    if isPrime:
        primes.append(possibleprime)
                 
        
#print(primes)

def prime(n):
    prime_factors = []
    n = int(n)
    for x in primes:
        if n % x == 0:
            prime_factors.append(x)
    return prime_factors
            
            
# n = 13195 
# print(prime(n))

n = 600851475143
print(prime(n))

#prime factors - ex.3

primes = []
for possibleprime in range (2,100000,1):
    isPrime = True
    for num in range(2, possibleprime, 1):
        if possibleprime % num == 0:
            isPrime = False
      
    if isPrime:
        primes.append(possibleprime)
                 
        
#print(primes)

def prime(n):
    prime_factors = []
    n = int(n)
    for x in primes:
        if n % x == 0:
            prime_factors.append(x)
    return prime_factors
            
            
# n = 13195 
# print(prime(n))

n = 600851475143
print(prime(n))

    
Source Link

Project Euler problem #3

My code works but would take 160 days to run lol.

#prime factors - ex.3

primes = [] for possibleprime in range (2,100000,1): isPrime = True for num in range(2, possibleprime, 1): if possibleprime % num == 0: isPrime = False

if isPrime:
    primes.append(possibleprime)
             
    

#print(primes)

def prime(n): prime_factors = [] n = int(n) for x in primes: if n % x == 0: prime_factors.append(x) return prime_factors

n = 13195

print(prime(n))

n = 600851475143 print(prime(n))

#prime factors - ex.3

primes = []
for possibleprime in range (2,100000,1):
    isPrime = True
    for num in range(2, possibleprime, 1):
        if possibleprime % num == 0:
            isPrime = False
      
    if isPrime:
        primes.append(possibleprime)
                 
        
#print(primes)

def prime(n):
    prime_factors = []
    n = int(n)
    for x in primes:
        if n % x == 0:
            prime_factors.append(x)
    return prime_factors
            
            
# n = 13195 
# print(prime(n))

n = 600851475143
print(prime(n))