First notice that f(1) divides 1, and hence f(1)=1. For all primes p, we have
p⋅f(p2n)=lcm(p⋅f(p2n),1)=lcm(p⋅f(p2n),f(12))=p⋅f(pn⋅1)=p⋅f(pn),
which shows that f(pn)=f(p2n) for all n. Now we show by induction on m that f(pm)=f(p). We know that f(p2)=f(p). Assume that f(pm)=f(p). Now
pf(p⋅pm)=lcm(p⋅f(p2),f(p2m))=lcm(p⋅f(p),f(pm))=p⋅f(p),and hence f(pm+1)=f(p).
Since f(p) divides p, we know that f(p)=pαp for αp∈{0,1}. For each prime pi, let f(pi)=piαpi with αpi∈{0,1}. For two primes p1=p2, we have
p1nf(p1n⋅p2m)=lcm(p1n⋅f(p12n),f(p22m))=lcm(p1n⋅p1αp1,p2αp2)=p1n⋅p1αp1⋅p2αp2,
and hence f(p1n⋅p2m)=p1αp1⋅p2αp2 for all non-negative integers n and m. By induction on r, it follows that
f(p1n1p2n2⋯prnr)=p1αp1p2αp2⋯prαpr.