Print a series of numbers divisible by 3 from 1 to n in python answer
Answers
Answered by
1
Answer:
n = int(input('Enter a number: '))
print("Numbers divisible by 3 from 1 to ", n, " are: ")
for i in range(3, n, 3):
print(i)
Answered by
3
The given problem is solved using language - Python.
n=int(input('Enter limit: '))
print('\nHere is your series:')
for i in range(3,3*n+1,3):
print(i,end=' ')
- Line 1: Accepts the limit from the user.
- Line 2: Display a message.
- Line 3: A loop is created to display the numbers.
- Line 4: Numbers are displayed using print() statement.
See attachment for output.
Attachments:
Similar questions