My code is
T=np.empty() for N in range ("some gemetric numbers: 1,2,4,8,16): T[N]= trap(f1,a,b,N)
This is what the program looks like
Advertisement
Answer
With generators:
def geom_generator(max_number): i = 1 while i < max_number: yield i i = i*2 for i in geom_generator(max_number=1000): # just a random sample # do something print (i)
Output:
1 2 4 8 16 32 64 128 256 512