Guys can anyone identify the mistake in this prg? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

17th Jan 2017, 5:28 AM
Akshobhya A
Akshobhya A - avatar
3 Answers
+ 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 ! ! !
17th Jan 2017, 6:04 AM
visph
visph - avatar
0
You are right visph. i made a mistake. but i have written a new code and uploaded it....it works fine..thank u
17th Jan 2017, 1:20 PM
Akshobhya A
Akshobhya A - avatar
0
i, j in range ? Won't work
18th Jan 2017, 9:00 PM
Amaras A
Amaras A - avatar