This is solution using C language
include <stdio.h>
int main() {
int N;
scanf(“%d”, & N);
if (N % 3 == 0)
{
printf(“%d”, N);
}
else if (N % 3!= 0 && N%8==0)
{
printf(“%d”, N+1);
}
else if(N%3!=0 && N%7==0)
{
printf(“%d”, N-1);
}
else if(N%3!=0 && N%10==0)
{
printf(“%d”, N-1);
}
else if(N%3!=0 && N%5==0)
{
printf(“%d”, N+1);
}
else if(N%3!=0 && N%4==0)
{
printf(“%d”, N-1);
}
else if(N%3!=0 && N%2==0)
{
printf(“%d”, N+1);
}
else
{
printf(“%d”,N-1);
}
}