| 1 | initial version |
Figured out the the reason as well: with
for w in range(1, N):
fill(w)
the type of w is int, and so is the type of h inside the inner loop in fill. So something like w/(w+h) uses integer division (on ints), giving 0.
On the other hand, with
w = 1
while w < N:
fill(w)
w += 1
the type of w is Integer, so w/(w+h) results in a proper fraction and not 0.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.