from itertools import combinations_with_replacement
def homogeneous(n, k):
R = PolynomialRing(ZZ, ['x%d' % (i+1) for i in range(n)])
return sum(prod(c) for c in combinations_with_replacement(R.gens(), k))
homogeneous(6, 4) # the next degree after this table