0
Guys can anyone identify the mistake in this prg?
print("hi welcome to the Permutation and Combination calculator\n") print ("Please enter an integer value for n") n=int(input()) print (" Please enter an integer value for r") r=int(input()) if n>0 and n>r : i=n j=n-r fn=1 fr=1 for i,j in range(1,101): fn*=i fr*=j i=i-1 j=j-1 return fn/fr
3 Antworten
+ 2
You don't have an 'else' case for your 'if' statement so when your condition is false ( maybe your mistake is here: 'n > r' instead 'n < r' ? ), you directly execute the last line, which use two variables not being neither declaring than assigning ^^
[EDIT]
AND YOU HAVE A RETURN STATEMENT BUT NO FUNCTION FROM WHICH TO RETURN ! ! !
0
You are right visph. i made a mistake. but i have written a new code and uploaded it....it works fine..thank u
0
i, j in range ? Won't work