Answer: Following code is in python
n=int(input("Enter integer ")) //taking n as an input
if n%2==0: //if divisible by 2
for i in range(n,0,-2): //n will be included
print(i)
else:
for i in range(n-1,0,-2): //else n won't be included
print(i)
OUTPUT :
Enter integer 26
26
24
22
20
18
16
14
12
10
8
6
4
2
Explanation:
An input is taken and converted to int type as the input is of string type in python. It is checked if a number is divisible by 2 as if it is, then number is included because it is an even number and range() method is used which takes 3 numbers as parameters - start, end and step. If the step is -2 then 2 is subtracted every time from n. n is not included if it is not an even number.