Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # target = 13195
- target = 600851475143
- sub_target = target
- current_factor = 2
- prime_factors = []
- while sub_target > current_factor:
- while sub_target % current_factor > 0:
- current_factor += 1
- prime_factors.append(current_factor)
- sub_target /= current_factor
- print "Greatest prime factor of %d is %d" % (target, prime_factors[-1])
- print "All prime factors: %s" % ", ".join([str(n) for n in prime_factors])
Add Comment
Please, Sign In to add comment