suite.py

Created by florian-allard

Created on May 01, 2018

232 Bytes

Pour un nombre donné en entrée, calcule la somme des carrés des chiffres qui le composent et affiche cette somme. Répète l’opération avec cette nouvelle somme comme nombre d’entrée.


from math import *
from kandinsky import *
def suite(a):
  for k in range(14):
    s=0
    while (a!=0):
      s=s+(10*modf(a/10)[0])**2
      a=modf(a/10)[1]
    a=round(s)
    #print(a)
    draw_string(str(a),20,15*k)