First try to get the algorithm right.
You only want to divide by prime numbers.
E.g. prime factors of 60 are 2,3 and 5.
But you also need to know to what power a given prime needs to be raised: 60 = 2^2 * 3 * 5
Prime factorization is not easy, it's computationally intens, that's why it's used in cryptography.
You can use the
Seive of Eratosthenes to gather prime numbers.
Note that for N the larges prime factor will always be <= square root of N.
So, for 600851475143 the largest prime factor will be <=775146
And for 13195, it will be <= 114.
For relative small numers (up to 10968163441) you can use
my unit that contains a list of the first 10000 primes as a starting point.
Bart