abcdabcdabcd...
On aimerait connaître le nombre d'entiers naturels multiples de 11 dont l'écriture décimale est de la forme N = abcdabcdabcd...abcd,
le motif abcd étant répété 2016 fois et a, b, c, d étant des chiffres (a non nul).
Écrire un programme python répondant à la question.
def structure(a,b,c,d) :
nb = ''
for i in range(2016):
nb += str(a)+str(b)+str(c)+str(d)
return nb
def nbStructure(a,b,c,d):
return int(structure(a,b,c,d))
def estMultipleDe11(n) :
return ( n%11 == 0 )
compteur = 0
for a in range(1,10):
for b in range(0,10):
for c in range(0,10):
for d in range(0,10):
n = nbStructure(a,b,c,d)
if estMultipleDe11(n) : compteur += 1
print(compteur)
Affichage :
819