Loop to find the maximum value of count_P that also satisfy P * count_P + Q * count_Q = N
while ( N > 0 ) : NEW_LINE INDENT if ( N % P == 0 ) : NEW_LINE INDENT count_P += N / P NEW_LINE N = 0 NEW_LINE DEDENT else : NEW_LINE INDENT N = N - Q NEW_LINE count_Q += 1 NEW_LINE DEDENT DEDENT