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)

- evhiness March 23, 2016 | Flag Reply
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

- narendra simha talluri May 20, 2016 | Flag Reply
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)

- MMN June 28, 2016 | Flag Reply
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)

- dean July 01, 2016 | Flag Reply
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)

- dean July 01, 2016 | Flag Reply
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)

- dean July 01, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

test

- test July 01, 2016 | Flag Reply
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

- Anonymous July 13, 2016 | Flag Reply
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))

- Anonymous August 30, 2016 | Flag Reply
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)

- Ravindhar August 30, 2016 | Flag Reply
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)

- MrKrisJack September 07, 2016 | Flag Reply
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

- Nueman September 17, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

it should be iterative

- Nueman September 17, 2016 | Flag Reply
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)

- Anonymous April 25, 2017 | Flag Reply
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)

- Vijetha May 11, 2017 | Flag Reply
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

- Anonymous December 10, 2017 | Flag Reply
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

- syedasifa95 August 19, 2019 | Flag Reply
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))

- Navnit Kumar August 30, 2016 | Flag Reply


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