#include<stdio.h>
int main()
{
int i, n, a=0, b=0;
printf("enter number : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i%2!=0)
{
if(i>1)
a = a + 2;
}
else
{
b = a/2;
}
}
if(n%2!=0)
{
printf("%d",a);
}
else
{
printf("%d",b);
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int i, n, a=0, b=0;
cout << "enter number : ";
cin >> n;
for(i=1;i<=n;i++)
{
if(i%2!=0)
{
if(i>1)
a = a + 2;
}
else
{
b = a/2;
}
}
if(n%2!=0)
{
cout << a;
}
else
{
cout << b;
}
return 0;
}
//Java program to find nth element of the series
import java.util.Scanner;
class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = 0, b = 0;
if(n % 2 == 0)
{
for(int i = 1 ; i <= (n-2) ; i = i+2)
{
a = a + 2;
b = a / 2;
}
System.out.print(b);
}
else
{
for(int i = 1 ; i < (n-2) ; i = i+2)
{
a = a + 2;
b = a / 2;
}
a = a + 2;
System.out.print(a);
}
}
}
n = int(input('enter the number:'))
a=0
b=0
for i in range(1,n+1):
if(i%2!=0):
a= a+2
else:
b= b+1
if(n%2!=0):
print('{}'.format(a-2))
else:
print('{}'.format(b-1))
n=int(input())
j=0
x=[0]
for i in range(n):
x.append(i)
j=j+2
x.append(j)
print(x)
print(x[n-1])
#include
int main ()
{
int n;
scanf(“%d”,n);
If(n%2!=2)
printf (“%d”,(n/2)*2);
else
printf (“%d”,(n/2-1));
return 0;
}
#include
using namespace std;
int main(){
int n;
cin>>n;
int ans;
if(n%2==0){
int ans=(n/2)-1;
cout<<ans;
}
else{
ans=n-1;
cout<<ans;
}
return 0;
}
Easy Python code :-
n = int(input())
if(n%2==0):
print((n-2)//2)
else:
print(n-1)
#python code
n = int(input(‘Enter the n value: ‘))
i = 0
for i in range(n):
if i%2 == 0 :
x = i
else:
x = int((i-1)/2)
print(x)
#Python code
n = int(input(‘Enter the n value: ‘))
i = 0
for i in range(n):
if i%2 == 0 :
x = i
else:
x = int((i-1)/2)
print(x)
num=int(input(“Enter positive integer only: “))
if num>20000:
print(“Can’t get the Output BCZ num is greater than 20000.”)
else:
if num%2==0:
print((num//2)-1)
else:
print(num-1)
Python code:
num=int(input())
if num%2!=0:
print(num-1)
else:
if num==0:
print(num)
else:
print((num-2)//2)
#include
using namespace std;
int main()
{
int Nth;
cin>>Nth;
Nth = Nth-1;
if((Nth)%2==0){
cout<<Nth;
}
else{
int k = (Nth-1)/2;
cout<<k;
}
}
#include
void main()
{
int n, x;
scanf(“%d”,&n);
if(n%2!=0)
x= 2*(n/2);
else
x = 1*(n-1)/2;
printf(“%d”,x);
}
#include
using namespace std;
int main(){
int n;
cin>>n;
if(n%2==0)cout<<(n-1)/2;
else cout<<n;
}
#include
using namespace std;
int main(){
int n;
cin>>n;
if(n%2==0)cout<<n;
else cout<<(n-1)/2;
}