Remove all triplets which have gcd equal to a multiple of i
for i in range ( 1000000 , 0 , - 1 ) : NEW_LINE INDENT for j in range ( 2 * i , 1000000 + 1 , i ) : NEW_LINE INDENT cnt [ i ] -= cnt [ j ] NEW_LINE DEDENT DEDENT print ( " Number ▁ of ▁ triplets ▁ with ▁ GCD " " ▁ { 0 } ▁ are ▁ { 1 } " . format ( K , int ( cnt [ K ] ) ) ) NEW_LINE