lundi 2 novembre 2015

Cant add 1 to variable?

The below is from MIT CS course, lecture three, question three.

x = 10
i = 1
while(i<x):
    if x%i == 0:
       print 'divisor ',i
    i = i+1 

I have managed to get the desired output using range but no matter how I format this example it either goes on displaying Division 1 or just hangs.

Aucun commentaire:

Enregistrer un commentaire