
\begin{python}
def fct(n):
    L = [] # liste vide
    for k in range(n+1):
        double = 2 * k
        carre = k ** 2
        somme_d, somme_c = 0, 0
        while double > 0:
            somme_d += double % 10
            double = double // 10

        while carre > 0:
            somme_c += carre % 10
            carre = carre // 10

        if somme_c == somme_d:
            L.append(k)

    return L
\end{python}

On obtient alors :

\begin{console}
>>> fct(100)
[0, 2, 9, 11, 18, 20, 29, 38, 45, 47, 90, 99]
\end{console}
