J's answer to Noob student's Junior College 2 H2 Maths Singapore question.

done {{ upvoteCount }} Upvotes
clear {{ downvoteCount * -1 }} Downvotes
J
J's answer
1022 answers (A Helpful Person)
Main comments section for a slightly different approach to second part's case the n = p² where p is prime.