5.5k views
3 votes
Write a pseudocode thats accept and then find out whether the number is divisible by 5 ​

User Doobist
by
5.1k points

1 Answer

7 votes

Answer:

input number

calculate modulus of the number and 5

compare outcome to 0

if 0 then output "divisible by 5"

else output "not divisible by 5"

Step-by-step explanation:

The modulo operator is key here. It returns the remainder after integer division. So 8 mod 5 for example is 3, since 5x1+3 = 8. Only if the outcome is 0, you know the number you divided is a multiple of 5.

User Florent
by
5.3k points