## JP Morgan Interview Question for Software Engineer / Developers

Country: United States
Interview Type: In-Person

Comment hidden because of low score. Click to expand.
0
of 0 vote

This site isn't for homework problems but:

def factorial(x):
v = 1
for i in range(1, x):
q *= i
print(v)

Comment hidden because of low score. Click to expand.
0
of 0 vote

>>> def factorial(x):
... q=1
... for i in range(1,x):
... q*=i
... print(q)
...
>>>
>>>
>>> factorial(5)
1
2
6
24

Comment hidden because of low score. Click to expand.
0
of 0 vote

def factorial(x):
v = 1
print v
for i in range(1, (x-1)):
v *= i
print(v)

factorial(10)

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def fact(v):
i = 1
for f in range(1, v+1):
i = i * f
return i

print fact(4)``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def fact(a):
i = 1
for f in range(1, a+1):
i *= f
return i

print fact(4)``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def fact(a):
i = 1
for f in range(1, a+1):
i *= f
return i

print fact(4)``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

test

Comment hidden because of low score. Click to expand.
0
of 0 vote

def fac(n):
if(n==0):
return 1
return n*fac(n-1)

fact=fac(5)
print fact

Comment hidden because of low score. Click to expand.
0
of 0 vote

def factorial(n):
if n == 1:
return n

return n*factorial(n-1)

if __name__ == '__main__':
print ("Factorial: %s" % factorial(5))

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def fact(n):
if n == 1:
return 1
else:
return n*fact(n-1)
print fact(5)``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def factorial(n):
product = 1
for i in range(2, n + 1):
product *= i
return product

print factorial(3)``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

something like this would be fine:

``````def factorial(n):
num = 1
while n >= 1:
num = num * n
n = n - 1
return num``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

it should be iterative

Comment hidden because of low score. Click to expand.
0
of 0 vote

def factorial(n):
sum = 0
for i in range(2,n+1):
if n == 0:
return 0
elif n==1:
return 1
else:
return sum = sum*i
return sum
if __name__ == '_main_':
print factorial(6)

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def fact (n):
res = 1
for i in range(n,1,-1):
res = res*i
print (res)

fact(5)``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def fact(n):

if n==0: return 1

result = 1
for i in range(1, n+1):
result = result*i
return result``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````def iterative_factorial(n):
factor = 1
for i in range(1, n+1):
factor = factor * i
return factor``````

Comment hidden because of low score. Click to expand.
-1
of 1 vote

``````def factorial(n):
if n == 1:
return n

return n*factorial(n-1)

if __name__ == '__main__':
print ("Factorial: %s" % factorial(5))``````

Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

### Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

### Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More