factorize' n (p:ps) = 
    let (q, k, done) = divideOut n p 0
        rest = if done then [] else ps
    in if k > 0
       then (p, k) : factorize' q rest
       else factorize' q rest
factorize' n (p:ps) = 
    let (q, k, done) = divideOut n p 0
        rest = if done then [] else ps
    in if k > 0
       then (p, k) : factorize' q rest
       else factorize' q rest
factorize' n (p:ps) = 
    let (q, k, done) = divideOut n p 0
        rest = if done then [] else ps
    in if k > 0
       then (p, k) : factorize' q rest
       else factorize' q rest