Computer Science, asked by joankim610, 3 months ago

Write function even() that takes a positive integer n as input and prints on the screen all numbers between, and including, 2
and n divisible by 2 or by 3, using this output format:
>>> even(17)
2, 3, 4, 6, 8, 9, 10, 12, 14, 15, 16,

Answers

Answered by jai696
2

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

def even(n):

li = [str(i) for i in range(1, n + 1) if i % 2 == 0 or i % 3 == 0]

return ", ".join(li)

print(even((n := int(input("n: ")))))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions