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)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.