Skip to content

Commit 5f63ae9

Browse files
authored
Update 3_odd_even_numbers.py
1 parent fd76ee9 commit 5f63ae9

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
max = int(input("Enter max number: "))
22

3-
odd_numbers = []
4-
5-
for i in range(max):
6-
if i%2 == 1:
7-
odd_numbers.append(i)
8-
9-
print("Odd numbers: ",odd_numbers)
3+
if max & 1 == 1: # if the max = 11 ; 11 & 1 it will give 1 then the remaining value is 1 which will lead to ODD Number else EVEN Number(also can use "and" otherthan "&")
4+
print("ODD")
5+
else:
6+
print("EVEN")

0 commit comments

Comments
 (0)