Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #12
- def gcd(x, y):
- while y != 0:
- (x, y) = (y, x % y)
- return x
- #9
- def prime(n):
- primefactor = []
- d = 2
- while d*d <= n:
- while (n % d) == 0:
- primefactor.append(d)
- n //= d
- d += 1
- if n > 1:
- primefactor.append(n)
- return primefactor
- def testGCD(a,b):
- pass
- d=gcd(10, 4)
- print ("gcd(10, 4)= ", d, 10/d, 4/d)
- print( gcd(4,10))
- def testPrime(n):
- factors = prime(n)
- print( "the prime factors of %d are"%(n), factors)
- prod = 1
- for f in factors:
- prod *= f
- print("Their product is ", prod)
- testPrime(360)
- testPrime(123456789)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement