Question on % and prime number

Hi everyone,
Julia newbie here :smiley: In my attempt to solve the following problem using Julia, which is almost a copy of a solution I came up using Python, I’m obviously not entering in the second while-loop (the println statement shows the ans variable-1).
Still lot to learn :slight_smile:

function Problem3()
    The prime factors of 13195 are 5, 7, 13 and 29.

    What is the largest prime factor of the number 600851475143 ?

    global ans = 600_851_475_143
    global factor = 2

    while factor * factor < ans
        while ans % factor == 0
            ans = ans ÷ factor
            factor += 1

    return ans

Any help would be appreciated

this is false in the first iteration so of course you’re not entering the inner while loop

julia> 600_851_475_143 % 2

OMG, messed up the increment in the outer loop :frowning: