Print Multiples of 5 Up to N

Print all multiples of 5 from 5 to n.

Logic BuildingBeginner
Logic Building
# Take n as input
n = int(input("Enter n: "))

# Print multiples of 5
print("Multiples of 5:")
for i in range(5, n + 1, 5):
    print(i, end=" ")
print()

Output

Enter n: 25
Multiples of 5:
5 10 15 20 25

Use range with step 5 to get multiples.

Key Concepts:

  • range(5, n+1, 5) gives multiples of 5
  • Step size 5 skips non-multiples
  • Efficient way to get multiples