Algorithm
Multiples
Adapted by Neilor Tonin, URI Brazil
Read two nteger values (A and B). After, the program should print the message "Sao Multiplos" (are multiples) or "Nao sao Multiplos" (aren’t multiples), corresponding to the read values.
Input
The input has two integer numbers.
Output
Print the relative message to the input as stated above.
Input Sample | Output Sample |
6 24 |
Sao Multiplos |
6 25 |
Nao sao Multiplos |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int A, B;
scanf("%d %d", &A, &B);
if (B % A == 0 || A % B == 0)
{
printf("Sao Multiplosn");
}
else
{
printf("Nao sao Multiplosn");
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <iostream>
using namespace std;
int main()
{
int x, y;
cin >> x >> y;
if(x < y){
if(y % x == 0){cout << "Sao Multiplos" << endl;}
else{cout << "Nao sao Multiplos" << endl;}
}else{
if(x % y == 0>{cout << "Sao Multiplos" << endl;}
else{cout << "Nao sao Multiplos" << endl;}
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with Java Programming
Code -
Java Programming
iimport java.util.Scanner;
public class Main {
public static void main(String[] args){
int A, B;
Scanner input =new Scanner(System.in);
A = input.nextInt();
B = input.nextInt();
if (B % A == 0 || A % B == 0) {
System.out.print("Sao Multiplosn");
}else {
System.out.print("Nao sao Multiplosn");
}
}
}
Copy The Code &
Try With Live Editor
Input
Output
#4 Code Example with Java Programming
Code -
Java Programming
a,b=map(int, input().split())
if (a%b==0)or(b%a==0):
print("Sao Multiplos")
else:
print("Nao sao Multiplos")
Copy The Code &
Try With Live Editor
Input
Output