Project Euler #148: Exploring Pascal's triangle.

  • + 1 comment
    import math
    f=math.factorial
    result=[]
    tc=int(raw_input())
    for i in range(tc):
    	n_row,n_col=raw_input().split(' ')
    	count=0
    	for r in range(int(n_row)):
    		c=0
    		while c<int(n_col) and c<r+1:
    			value=(f(r)/(f(c)*f(r-c)))
    			if value%7!=0:
    					count=count+1	
    			c=c+1	
    	result.append(count)
    
    for i in result:
    	print i
    

    I'm getting timed out!