A number is divisible by if the remainder of dividing by equals . To solve the problem, use a conditional operator.
Algorithm implementation
Read the input data.
scanf("%d %d",&a,&b);Check whether is divisible by . Depending on the result, print the corresponding answer.
if (a % b != 0)
printf("%d %d\n",a/b,a%b);
else
printf("Divisible\n");Java implementation
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
int a = con.nextInt();
int b = con.nextInt();
if (a % b != 0)
System.out.print(a/b + " " + a%b);
else
System.out.println("Divisible");
con.close();
}
}Python implementation
Read the input data.
a, b = map(int,input().split())Check whether is divisible by . Depending on the result, print the corresponding answer.
if a % b != 0:
print(a // b, a % b)
else:
print("Divisible")