I don't happen to have the formula memorized (but I know it is in my Calculus book) so let's work it out:
Let (x,y,z) be the point on the line closest to (3, 5, 1). A vector pointing from (3, 5, 1) to (x, y, z) is (x-3)i+ (y-5)j+ (z-1)k. Of course, the line from (3, 5, 1) to (x, y, z) must be perpendicular to the given line. (If not, construct a right triangle have that line as hypotenuse and the given line as "opposite" side. Since the hypotenuse of a right triangle is the longest side in any right triangle, it can't be the shortest distance.)
A vector in the direction of the given line is, of course, 4j+ 4k and that must be perpendicular to (x-3)i+ (y-5)j+ (z-1)k:
(4j+ 4k).((x-3)i+ (y-5)j+ (z-1)k)= 4(y-5)+ 4(z- 1)= 0 so 4y- 20+ 4z- 4= 0 and 4y+ 4z= 24 or y+ z= 6. We now can write the point (x,y,z) as (0, y, 6-y) (x= 0 for any point on the line and clearly z= 6- y).
The distance function is
D= \sqrt{(x-3)^2+ (y- 6)^2+ (z-1)^2}= \sqrt{9+ (y-6)^2+ (5-y)^2}
Minimize that, or better,
D^2= 9+ (y-6)^2+ (5-y)^2= 9+ y^2- 12y+ 36+ 25-10y+ y^2= 3y^2-22y+ 70