The spectra of charged particles produced within the pseudorapidity window vertical bar eta vertical bar < 1 at root s(NN) = 5 : 02 TeV are measured using 404 mu b(-1) of PbPb and 27.4 pb(-1) of pp data collected by the CMS detector at the LHC in 2015. The spectra are presented over the transverse momentum ranges spanning 0 : 5 < p(T) < 400 GeV in pp and 0 : 7 < p(T) < 400 GeV in PbPb collisions. The corresponding nuclear modification factor, R-AA, is measured in bins of collision centrality. The R-AA in the 5% most central collisions shows a maximal suppression by a factor of 7-8 in the p(T) region of 6-9 GeV. This dip is followed by an increase, which continues up to the highest p(T) measured, and approaches unity in the vicinity of p(T) = 200 GeV. The R-AA is compared to theoretical predictions and earlier experimental results at lower collision energies. The newly measured pp spectrum is combined with the pPb spectrum previously published by the CMS collaboration to construct the pPb nuclear modification factor, R-pA, up to 120 GeV. For p(T) > 20 GeV, R-pA exhibits weak momentum dependence and shows a moderate enhancement above unity.