Advertisement
Guest User

nested for loops python

a guest
Apr 27th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def simpletest():    
  2.    
  3.     '''
  4.    I am going to just test the algo listing with assumption
  5.    degree n = 2
  6.    max = dim(m_p(n-1)) = 3,
  7.    so j1 j2 and upto j3 are required for every entry into m_p(degree2)
  8.    Lets just print j1,j2,j3 to verify if the function
  9.    works in other general version where the number of for loops is not known
  10.    '''
  11.     n = 2
  12.     count = 0
  13.     for j1 in range(n, -1, -1):
  14.         for j2 in range(n -j1, -1, -1):
  15.             j3 = (n-(j1+j2))
  16.             count = count + 1
  17.             print 'To calculate m_p(%d)[%d], j1,j2,j3 = ' %(n,count), j1, j2, j3
  18.            
  19.     assert(count==6)        # just a checkpoint. See P.169 for a proof
  20.     print 'No. of entries =', count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement