Chef and Gcd Queries

LinK: https://www.codechef.com/MARCH18A/problems/GCDCNT . I have difficulty in understanding the editorial,Can anyone explain their approach clearly.

@john_smith_3,@taran_1407,@meooow can u tell your approach?