1

For any given n , I need the following to happen.

def count(n):
  for i in range(0,5):
    for j in range(0,i+1):
      for k in range(0,j+1):
        .......
          n nested loops 
             count=count+1 
   return count 

I would like to know if there is a more concise way of achieving this above code segment.

the code has to return 5,15,35,70 on input of 1,2,3,4 .

0 Answers0