5. factorial


my code for factorial

import math

def factorial(x):
    user = int(raw_input("Please enter a number: "))
    if(user == 1):
        return 1
        return user * len(user-1)
        print user

Oops, try again. factorial(1) resulted in an error: invalid literal for int() with base 10: ''

I tried something different. Multiplying the no. entered by user into len(user - 1)
can u let me know where m wrong!

5 Factorial question - why does this code work?

don't use raw_input, and use x the function parameter, the exercises tries if your code works by calling the function with different arguments, so you should use the function parameter (x) of which you should calculate the factorial


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