The Fourier coefficients v2and v3characterizing the anisotropy of the azimuthal distribution of charged particles produced in PbPb collisions at √sNN=5.02TeVare measured with data collected by the CMS experiment. The measurements cover a broad transverse momentum range, 1 <pT<100GeV/c. The analysis focuses on the pT>10GeV/crange, where anisotropic azimuthal distributions should reflect the path-length dependence of parton energy loss in the created medium. Results are presented in several bins of PbPb collision centrality, spanning the 60% most central events. The v2coefficient is measured with the scalar product and the multiparticle cumulant methods, which have different sensitivities to initial-state fluctuations. The values from both methods remain positive up to pT∼60–80GeV/c, in all examined centrality classes. The v3coefficient, only measured with the scalar product method, tends to zero for pT 20GeV/c. Comparisons between theoretical calculations and data provide new constraints on the path-length dependence of parton energy loss in heavy ion collisions and highlight the importance of the initial-state fluctuations.