Charged-particle nuclear modification factors in PbPb and pPb collisions at sqrt(s_NN)=5.02 TeV