@Korkin/

euler3

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys, itertools

def primefactors(n):
    start = 3
    end = n
    biggestFactor = 1
    while n%2==0:
        n/=2
        end=n
        biggestFactor = 2
    notPrime = True
    while n>1 and notPrime:
        notPrime = False
        i = start
        while i*i <= end:
            if n%i == 0:
                n/=i
                print(i)
                end=n
                biggestFactor = i
                notPrime = True
                break
            i+=2
    return max(biggestFactor, int(n))

print(primefactors(60085147514374892307507438392472))