/*

Largest prime factor
Problem 3
Published on Friday, 2nd November 2001, 12:00 pm; Solved by 256800
The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

By: dbk

*/
#include <stdio.h>

#define CALCULAR 600851475143
#define MAX 1000000

int main(int argc, char const *argv[])
{

	long res = 0;
	long valor = CALCULAR;

	for (int i = 2; i < MAX; i++)
	{
		while ( valor % i == 0)
		{
			valor /= i;
			res = i;
		}

	}

	printf("Mayor factor primo: %ld\n", res);

	return 0;
}