python 3.x - Modulo remainder equals to zero, only first two products taken into account in the loop -


i'm trying find divisors ("i" in case) of given number ("a" in case) no remainder (a % == 0). i'm running loop goes trough vales of starting 1 value of a. problem first 2 products of % == 0 taken account. rest left out. why that?

here code in python3:

a = 999 = 1 x = 0 d = []  while (i < a):     x = /     if(x % == 0):         d.append(i)     += 1  print (d) 

the output of code is:

[1, 3] 

instead of listing divisors. have checked different values of , can't find error.

the behavior of script correct. see yourself:

enter image description here

i think it's logic, , trying achieve is:

a = 999 = 1 d = []  while (i < a):     if(a % == 0):         d.append(i)     += 1  print (d) 

outputs:

[1, 3, 9, 27, ...] 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -