Hackerrank – Project Euler+ #003 – Largest prime factor

Hackerrank – Problem description

The problem description – Hackerrank.

Solution

We can use the algorithm where we find out a list of all prime number divisor – prime factorization.

Let find the beginning prime number. The smallest prime number is 2. We divide the given number with actual divisor (actual prime number) until the division is possible. Then we change the prime number divisor with next prime number. We continue this steps until the division result is smaller than 1. Pick the biggest divisor.

There are other prime factor algorithms, e. g. Pollard Rho or Quadratic_sieve

I created solution in:

All solutions are also available on my GitHub profile.

Ruby

Leave a Reply

Your email address will not be published. Required fields are marked *