117k views
2 votes
Proposer un programme qui détermine à partir de deux entier a et b si a est un multiple de b

User Joao Lopes
by
7.5k points

1 Answer

0 votes

Answer:

To determine if a is a multiple of b, you can use the modulo operator (%). The modulo operator calculates the remainder of a division operation.

Here's a program in Python that can determine if a is a multiple of b:

1. Start by taking the values of a and b as input from the user.

2. Use the modulo operator to calculate the remainder of a divided by b: remainder = a % b.

3. Check if the remainder is equal to 0. If it is, then a is a multiple of b.

4. If the remainder is not equal to 0, then a is not a multiple of b.

Here's the program in Python:

```

a = int(input("Enter the value of a: "))

b = int(input("Enter the value of b: "))

remainder = a % b

if remainder == 0:

print(a, "is a multiple of", b)

else:

print(a, "is not a multiple of", b)

```

For example, if the user enters a = 10 and b = 5, the program will output "10 is a multiple of 5". But if the user enters a = 7 and b = 4, the program will output "7 is not a multiple of 4".

User Kemal AL GAZZAH
by
7.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.