Checking whether a number is divisible by a given number

Hi! I’m trying to ask the students to input a number that is divisible by both 25 and 8, and I want it marked correct or incorrect on the teacher dashboard.

I was thinking I could check to see whether the input is on the line y = 200x, where x is an integer, but I’m not sure how to make that happen in CL.

Thanks!

You could use modular math here:

check= numericValue(`\mod(${input.numericValue},200)`)=0
correct: check
1 Like

That worked! Thanks so much.

You’re welcome. You could also use a variable for the 200 if you wanted to change up your divisors:

a=25
b=8
d=numericValue(`\lcm(${a},${b})`)
check= numericValue(`\mod(${input.numericValue},${d})`)=0
correct: check
1 Like