Problem #3 - Largest Prime Factor

The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of the number 600851475143?

Sadly, many of these early problems have only one type of solution. Prime factorization doesn't allow for much creativity, so here's my solution in plain, boring JavaScript:

function largestPrime(n, factor){
        largestPrime(n/factor, factor)
    }else if(factor<Math.sqrt(n)){
        largestPrime(n, factor+1)
        return n