JP Morgan Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

def fuzzbuzz():
    for i in xrange(1,101):
        if i % 15 == 0:
            print 'fuzzbuzz'
        elif i % 3 == 0:
            print 'fuzz'
        elif i % 5 == 0:
            print 'buzz'
        else:
            print i

- fjw March 03, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 vote

I don't like repeating my ifs so I went with this approach.

for i in range(1,101):
	t=((15,"fuzzbuzz"),(5,"buzz"),(3,"fuzz"),(i,i))
	for (k, w) in t:
		if i%k==0:
			print(w) 
			break

- zasod August 02, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

for i in range(0,100):
   if i % 3 == 0:
      if i % 5 == 0:
        print 'fuzzbuzz'
      else:
        print 'fuzz'
   elif i % 5 == 0:
     print 'buzz'

- Prints perfectly as expected March 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

for i in range(0,100):
   if i % 3 == 0:
      if i % 5 == 0:
        print 'fuzzbuzz'
      else:
        print 'fuzz'
   elif i % 5 == 0:
     print 'buzz'

- Anonymous March 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

if __name__ == '__main__':
   
    for i in range(1,101):
        a=''
        if i%3 == 0:
            a = 'fuzz'
        if i%5 == 0:
            a+='buzz'
        if i%3 <>0 and i%5 <>0:
            a=str(i)
        print a

- Dgh April 12, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

if __name__ == '__main__':
   
    for i in range(1,101):
        a=''
        if i%3 == 0:
            a = 'fuzz'
        if i%5 == 0:
            a+='buzz'
        if i%3 <>0 and i%5 <>0:
            a=str(i)
        print a

- Dgh April 12, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

numbers = list(range(1, 101))
numbers[2::3] = 'fizz'
numbers[4::5] = 'buzz'
numbers[14::15] = 'fizzbuzz'

for n in numbers:
	print(n)

- dan June 28, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

number=1
while number<=100:
if(number%3 == 0):
if(number%5 == 0):
print "fuzzbuzz"
else:
print "fuzz"
else:
if(number%5 == 0):
print "buzz"
else:
print number

number= number+1

- MMN June 28, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for i in range(1,100):
d=True
if(i%3==0 and i%5==0):
print "fuzzbuzz"
d=False
else:
if(i%3==0):
print "fuzz"
d=False
if(i%5==0):
print "buzz"
d=False
if(d):
print i

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

for i in range(1,100):
if(i%3==0):
if(i%5==0):
print "fuzzbuzz"
else:
print "fuzz"
else:
if(i%5==0):
print "buzz"
else:
print i

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

for x in range(1,101):
        print (("fuzzbuzz"+str(x) if(x%5==0) else "fuzz"+str(x)) if (x%3==0) else ("buzz"+str(x) if (x%5==0) else x))

- Siddhesh Sathe July 15, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for x in range(1,101):
        print (("fuzzbuzz"+str(x) if(x%5==0) else "fuzz"+str(x)) if (x%3==0) else ("buzz"+str(x) if (x%5==0) else x))

- Siddhesh Sathe July 15, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for i in range(1, 101):
    mul3 = not bool(i % 3)
    mul5 = not bool(i % 5)
    out = ''
    out += ('fuzz' if mul3 else '')
    out += ('buzz' if mul5 else '')
    out = out or i
    print out, '(%s)' % i

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

def buzzfuzz(i):
for i in xrange(1,i):
if i%3 == 0:
if i%5 == 0:
print 'buzzfuzz'
else:
print 'buzz'
elif i%5 == 0:
print 'fuzz'
else:
print i

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

def buzzfuzz():
for i in xrange(1,101):
if i%3 == 0:
if i%5 == 0:
print 'buzzfuzz'
else:
print 'buzz'
elif i%5 == 0:
print 'fuzz'
else:
print i

- nidhi.jadon July 21, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for i in range(1,100):
        if i % 3 == 0 and i % 5 == 0:
                print 'fuzzbuzz'
        elif i % 3 == 0:
                print 'fuzz'
        elif i % 5 == 0:
                print 'buzz'
        else:
                print i

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

for i in range(1,100):
        if i % 3 == 0 and i % 5 == 0:
                print 'fuzzbuzz'
        elif i % 3 == 0:
                print 'fuzz'
        elif i % 5 == 0:
                print 'buzz'
        else:
                print i

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

for value in range(1,100):
if value%3==0 and value%5 == 0:
print("fuzzbuzz")
elif value%3 == 0 :
print("fuzz")
elif value%5 ==0 :
print("buzz")
else:
print(value)

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

for value in range(1,100):
    if value%3==0 and value%5 == 0:
        print("fuzzbuzz")
    elif value%3 == 0 :
        print("fuzz")
    elif value%5 ==0 :
        print("buzz")
    else:
        print(value)

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

Can be done easily using List Comphrension:

for i in ['fuzzbuzz' if (not x%3) and (not x%5) else 'fuzz' if not x%3 else 'buzz' if not x%5 else x for x in range(1, 101)]:
	print (i)

- Swadeep August 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

['fuzzbuzz' if (not x%3) and (not x%5) else 'fuzz' if not x%3 else 'buzz' if not x%5 else x for x in range(1, 101)]

- Swadeep August 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

hello

- Swadeep August 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can be done using list comphrension:

a = ['fuzzbuzz' if (not x%3) and (not x%5) else 'fuzz' if not x%3 else 'buzz' if not x%5 else x for x in range(1, 101)]
for i in a:
    print (i)

- hathi29 August 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for n in range(1, 101):
    multiple_of_3 = (n % 3) == 0
    multiple_of_5 = (n % 5) == 0
    if multiple_of_3 and multiple_of_5:
        print("fizzbuzz")
    elif multiple_of_3:
        print("fizz")
    elif multiple_of_5:
        print("buzz")
    else:
        print(n)

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

for i in range(1,101):
	if ( i%3 == 0 and i%5 == 0):
		print "FuzzBuzz"
	elif ( i%3 == 0 ):
		print "Fuzz"
	elif ( i%5 == 0 ):
		print "Buzz"
	else:
		print i

- mukes72 December 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/python

x=16
i=1

while(i <= x):
if(i % 3) == 0:
print "buzz"
i=i+1
elif(i % 5) == 0:
print "juzz"
i=i+1
else:
print i
i=i+1

- Anonymous February 28, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for i in range (1,100):
if i%3 ==0 and i%5 ==0:
print("fuzzbuzz")
elif i%5 == 0:
print("buzz")
elif i%3 == 0:
print("fuzz")

- Anonymous June 06, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for i in range (1,100):
if i%3 ==0 and i%5 ==0:
print("fuzzbuzz")
elif i%5 == 0:
print("buzz")
elif i%3 == 0:
print("fuzz")

- ashish June 06, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def FuzzBuzz():
for num in range(1,101):
       if((num%3==0)and(num%5==0)):
           print('fuzzbuzz')
       elif(num%3==0):
           print('fuzz')
       elif(num%5==0):
           print('buzz')
       else:
           print(num)

- Anonymous September 22, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def FuzzBuzz():
for num in range(1,101):
       if((num%3==0)and(num%5==0)):
           print('fuzzbuzz')
       elif(num%3==0):
           print('fuzz')
       elif(num%5==0):
           print('buzz')
       else:
           print(num)

- Chinmoy Padhi September 22, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for i in range(0, 101):
if i%3 == 0 and i %==5 == 0: print("fuzzbuzz")
elif i%3 == 0: print("fuzz")
elif i%5 == 0: print("buzz")

- syedasifa95 August 19, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

for i in range(0,100):
if i % 3 == 0:
if i % 5 == 0:
print 'fuzzbuzz'
else:
print 'fuzz'
elif i % 5 == 0:
print 'buzz'

- Prints perfectly as expected March 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

val3 = xrange(0,100,3)
print val3

val5 = xrange(0,100,5)
print val5




for i in xrange(1,100,1):
    if i in val3:
        print "fuzz",
    elif i in val5:
        print "fuzzbuzz",
    else:
        print i,

- sundar May 22, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

val3 = xrange(0,100,3)
print val3

val5 = xrange(0,100,5)
print val5




for i in xrange(1,100,1):
    if i in val3:
        print "fuzz",
    elif i in val5:
        print "fuzzbuzz",
    else:
        print i,

- sundar May 22, 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