Check if a number is a divisor of another number

Challenge Level: Growing experience

Learning outcomes

Students will be able to:

Requirement:

Write a program that asks the user to enter two numbers and displays a message saying if the second number is a divisor of the first number.

Testing examples:

Your program should display the outputs shown in this table for the given inputs provided;

Input Output
20
4
4 is a divisor of the number 20.
20
6
6 is not a divisor of the number 20.

Languages

Scratch

What it should look like

Click on the green flag to see the expected output of your program.

Recommended blocks
when green flag clicked
set [number1 v] to (answer)

set [number2 v] to (answer)
ask [Enter the 1st number:] and wait

ask [Enter the 2nd number:] and wait
say [Enter 2 numbers and I'll tell you if the second number is a divisor of the first number.] for (5) secs

say (join (join (number2) [ is a divisor of the number ]) (number1))

say (join (join (number2) [ is not a divisor of the number ]) (number1))
if <((number1) mod (number2)) = [0]> then
else
end
Hints
  • Divisor is a number that divides into another without a remainder (i.e. a number modulo its divisor is 0). You can find the () mod () block under the “operators” script.

Show Scratch solution

Python