def get_list_ab(a, b, N):
    """
        正整数序列Q中 的每一个元素都至少能被正整数a和b中的一个整除,现给定a和b,需要计算出Q中的前几项?
        例如:当a=3,b=5,N=6时,序列为3,5,6,9,10,12
        1)设计一个函数void generate(int a,int b, int N,int *Q)计算Q的前几项
        2)设计测试数据来验证函数程序在各种输入下的正确性
    :return:
    """
    # num = 0
    # list_temp = [a, b]
    # for i in range(2, N):
    #     temp1 = a*i
    #     temp2 = b*i
    #     list_temp.append(temp1)
    #     list_temp.append(temp2)
    #
    # list_sort = sorted(list_temp)
    # print(list_sort[:N])
    # return list_sort[:N]
    num = 0
    temp_one = (a*i for i in range(1, N+1))
    temp_two = (b*i for i in range(1, N+1))

    data1 = temp_one.__next__()
    data2 = temp_two.__next__()
    while num < N:
        if data1 < data2:
            print(data1)
            data1 = temp_one.__next__()
        elif data1 > data2:
            print(data2)
            data2 = temp_two.__next__()
        else:
            print(data1)
            data1 = temp_one.__next__()
            data2 = temp_two.__next__()

        num += 1

if __name__ == '__main__':
    get_list_ab(3,7,8)