def fct(n):
    for k in range(n+1):
        s = 0
        x = k**2
        while x > 0:
            u = x % 10
            s = s + u
            x = x // 10

        if s == k:
            print(k, end=' ')
