Ask coding questions

← Back to all posts
Why is this code not work (function for 1! + 2! + 3! + ... + N!). New to python, code may be wrong
BhaiBhai

import numpy

def sumFactorial(n):
n_range = list(range(1, n))
def Factorial(n):
ans_fact = 1

while len(n_range) > 0:
var = numpy.prod(n_range) + numpy.prod(n_range.pop(-1))
thingo = Factorial(n)
return var + thingo

Voters
BhaiBhai
Comments
hotnewtop
TheDNAHero

Pretty sure it’s because you didn’t print anything. Instead of return, write print