# Series of Even Number and its Derived Number | 0,0,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8....... This series is a mixture of 2 series - all the odd terms in this series from even numbers in ascending order and every even terms is derived from the previous term using the formula (x/2)

Consider the below series:

0,0,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8.......

This series is a mixture of 2 series - all the odd terms in this series from even numbers in ascending order and every even terms is derived from the previous term using the formula (x/2).
Write a program to find the Nth term in this series.

The value N in a positive integer that should be read from STDIN. The Nth term that is calculated by the program should be written to STDOUT. Other than the value of Nth term, no other characters / string or message should be written to STDOUT.

For Example:
If N = 10, the 10th term of the series is to be derived from 9th term in the series. The 9 term in the series is 8 so the 10th term is (8/2)=4. Only the value 4 should be printed on STDOUT.
You can assume that Number will not exceed 20,000.

#include <stdio.h>
int main(void) {

int n;
scanf("%d", &n);
if (n % 2 == 0) {
n = n / 2;
n = 2 * (n - 1);
printf("%d",n/2);
}
else {
n = (n / 2) + 1;
n = 2 * (n - 1);
printf("%d",n);
}
return 0;
}

Input:  11
Output:  10

Input:  12
Output:  5