Write a phyton program for executing the Fizz-Buzz problem. Quite simple, ain't it? Try it. Attach the output with your program. (Note :- Take n = 100).
Here is a fact:
If you could do it in less than a minute, you are better than 99.5% programmers all over the world.
Answers
Answered by
5
ɧɛƖƖơ ɱąɬɛ
Answer:
ᴘʟᴇᴀsᴇ ʀᴇFᴇʀ ᴛᴏ ᴛʜᴇ ᴀᴛᴛᴀᴄʜᴍᴇɴᴛ Fᴏʀ ᴀɴsᴡᴇʀ :)
__________________
ɧơ℘ɛ ıɬ ɧɛƖ℘ʂ ყơų ☺
__________________
Attachments:
Answered by
2
This is Fastest:
for i in range(1, 101):
if i % 3 == 0 and i % 5 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
And This one is the memory efficient as Modulo Operator is not used:
m3 = 0
m5 = 0
for i in range(1, 101):
m3 = m3+1
m5 = m5+1
if m3 == 3:
print("Fizz", end="")
m3 = 0
if m5 == 5:
print("Buzz", end="")
m5 = 0
if m3 == 0 or m5 == 0:
print()
if m3 != 0 and m5 != 0:
print(i)
Attachments:
Similar questions