5. Factorial


#1



i am having trouble with this factorial thing. Can anyone please help me please?

https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/5?curriculum_id=4f89dab3d788890003000096#


Oops, try again. factorial(1) returned [1] instead of 1
the console window says none


def factorial(x):
    total = []
    answer = 1
    def listing(x):    
        while int(x) > 0:
            total.append(x)
            x -=  1
        return total
    return listing(x)
    def multiplying(x):  
        for n in total:
            answer *= n
            return answer
    return multiplying(x).


#2

use a recursive function.


#3

If you don't know what I mean you can go to Youtube Khanacademy has videos on it. https://www.youtube.com/watch?v=o920mj0NbhE&t=16s :slight_smile:


#4

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