Project Euler : Problem 3



Problem

Link to problem page

The prime factors of $13195$ are $5, 7, 13$ and $29$.

What is the largest prime factor of the number $600851475143$?

Solution

Use "inspect source" to see the source code

Explaination

Start with $a = 2$. See if it divides the start number $b = 600851475143$. Let $c = b / a$. If $c$ is an integer, set $b$ equal to $c$. If not, increment $a$ by 1 and try again. Stop when $a$ equals $b$, and $a$ is the result.

Comments

Popular Posts