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

User Ricky Cook
by
5.6k points

1 Answer

2 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"

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 Nilsi
by
4.9k points