Using a conditional operator, check whether is divisible by both and simultaneously.
Algorithm implementation
Read the input data.
scanf("%d %d %d", &n, &a, &b);Check whether is divisible by both and simultaneously. Depending on the result, print the corresponding answer.
if (n % a == 0 && n % b == 0)
printf("YES\n");
else
printf("NO\n");Java implementation
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
int n = con.nextInt();
int a = con.nextInt();
int b = con.nextInt();
if (n % a == 0 && n % b == 0)
System.out.println("YES");
else
System.out.println("NO");
con.close();
}
}Python implementation
Read the input data.
n, a, b = map(int,input().split())Check whether is divisible by both and simultaneously. Depending on the result, print the corresponding answer.
if n % a == 0 and n % b == 0:
print("YES")
else:
print("NO")