Skip to content

Multiples of Five

kyra-ptn edited this page Aug 14, 2025 · 6 revisions

Unit 1 Session 2 (Click for link to problem statements)

U-nderstand

Understand what the interviewer is asking for by using test cases and questions about the problem.

P-lan

Plan the solution with appropriate visualizations and pseudocode.

General Idea: Loop from 5 to 100, stepping up by 5 each time.

Alternate Idea:: Loop from 5 to 100. If a number is divisible by 5, print the number.

⚠️ Common Mistakes

  • Make sure your loop doesn't exclude the last value (100).

I-mplement

def multiples_of_five():
    for num in range(5, 101, 5):
         print(num)

print(multiples_of_five())
# Output:
# 5
# 10
# 15
# 20
# 25
# 30
# 35
# 40 ....
# 100

Alternative Solution:

def multiples_of_five():
    for num in range(5, 101):
        if num % 5 == 0:
            print(num)


print(multiples_of_five())
# Output:
# 5
# 10
# 15
# 20
# 25
# 30
# 35
# 40 ....
# 100
Clone this wiki locally