Factorial, HELP PLEASE!



_My code is working fine, but it's not working the way I want it to._  
**def factorial(x):**
**    if x ==1:**
**        print 1**
**    while x>1:**
**        x-=1 **
**        print x **
The above code will count down from 4. However, I want it to include the number 4 and not just start counting down. I managed to fix this issue, but doing so conflicted with the goal of the assigment --> multiplying the numbers together. 
Any help is appreciated, but please do not go above what I asked. In other words, don't solve the rest of the assignment as I want to solve it by myself. 
Thanks in advance :)


def factorial(x):
temp = x

if temp == 1:
    print temp
if temp >= 2:
    print temp
    x -= 1

Your issue was in the decrement location. If you decrement before printing, you will only see the decremented value and no the initial value (in your case 4).


Thank you very much!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.