I am solving an exercise that asks me to enter a value for example: 5 and print the first 5 natural numbers in the case:
entry:
Type the value of n: 5
- 1
- 3
- 5
- 7
- 9
The code I wrote works however does not seem to me the best logic for solving it. Would anyone else have known any other "simple" solution because I am still learning
n = int(input("Digite o valor de n: "))
i = 1
while i <= (n+n):
if i % 2 != 0:
print(i)
i += 1
else:
i += 1