Example 1:
Input:
3 (Value of N)
Output:
3 (Block number )
Example 2:
Input:
13 (Value of N)
Output:
5 (Block number )
Code In JAVA:
import java.util.*;
class Main
{
public static void main(String[] args)
{
Scanner sc=new
Scanner(System.in);
int n=sc.nextInt();
int r=n%8;
if(r==0)
System.out.println(2);
else if(r<5)
System.out.println(r);
else
System.out.println(10-r);
}
}
Code in C:
#include <stdio.h>
int main()
{
int n;
scanf("%d",&n);
int r;
r=n%8;
if(r==0)
printf("2");
else if(r<5)
printf("%d",r);
else
printf("%d",(10-r));
return 0;
}
Output:
13
5
Comments
Post a Comment