simple factorials

i dont know why its telling that my code is giving wrong answer when i submit my code and checked it
code is in python 3.3
print(‘enter no of testcases you want to test’)
x={}
y=int(input())
print(’ now enter your inputs’)
for k in range(y):
x[k]=int(input())

for j in range(y):
i=1
for i in range(2,x[j]+1):
i=i*(i-1)
print(‘factorial of’, x[j], ‘is’, i)

@upbeast your logic is wrong, but what you are thinking is correct. only 3 mistakes in your code.corresponding changes are:

  1. change 1: instead of i=1 put k=1
  2. change 2: for i in range(2,x[j]+2)
  3. change 3: instead of i=i*(i-1) put k=k*(i-1)
    because k will store the product what ever you calculated but in i*(i-1) it doesn’t store your product.
    i*(i-1) will calculate (2)(1),(3)(2),(4)(3),(5)(4) for x[j]=5 which will result 20 at last,but required answer is 120.your AC code with changes can be viewed here. hope you understand :slight_smile:

@nanda19 It is good that you are helping him but always try to give test cases where the code fails and ask people to correct mistakes on their own. If they are still stuck then you can correct the code.

@kcahdog from now i will implement it.thanks for suggesting me