Decrease the number by 1. If the resulting number is odd, then it is the answer. Otherwise, decrease once more by 1.
Algorithm Implementation
Read the input value .
scanf("%d", &n);Decrease the number by 1.
n--;If is even, then decrease it once more by 1.
if (n % 2 == 0) n--;Output the answer.
printf("%d\n", n);Java Implementation
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
int n = con.nextInt();
n--;
if (n % 2 == 0) n--;
System.out.println(n);
con.close();
}
}Python Implementation
n = int(input())
n -= 1
if n % 2 == 0: n -= 1
print(n)