Again "pseudo-code" for C++ program. Quite primitive and simple, but I post it anyway. Generalized to take even even number as parameter.
Finding the biggest factor
def biggest_factor(number):
factor = 2
while not (number % factor) and number > factor:
number /= factor
factor = 3
limit = factor * factor
while limit <= number:
while not (number % factor) and number > factor:
number /= factor
#print factor,number
limit += 4*(factor+1)
factor += 2
return number
print biggest_factor(600851475143)
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.