# Checking if a number is divisible by 25 (or any number)

Hey! I could use a little help with Pulpscipt. Is there a way to check is a var is divisible by a certain number? Currently I've got this working code, but I think it could be cleaner:

``````if count==25 then
ytile++
xtile = 0
elseif count==50 then
ytile++
xtile = 0
elseif count==75 then
ytile++
xtile = 0
elseif count==100 then
ytile++
xtile = 0
``````

Basically I need to do something every 25 times in a loop, anyone have any ideas?

Youâ€™re looking for an operator called modulo, often referred to as just â€śmodâ€ť and represented as `%`. It returns the remainder when the first operand is divided by the second. For example: `7 % 2` â€” spoken â€śseven mod twoâ€ť â€” is 1.

For your use case, youâ€™ll want to check if a number mod 25 is zero, meaning there is no remainder when dividing by 25:

``````if count % 25 == 0 then
ytile++
xtile = 0
end
``````
1 Like

Oh, I just realized that the mod operator isn't available in PulpScript. However, this thread contains a workaround.

Ah perfect, that thread worked for me! If anyone was wondering, here's the working code:

``````//check if count is multiple of 25 (one complete row)
mod = count
mod /= 25
mod -= floor mod
mod *= 25

//if yes, let's move to the next row
if mod==0 then
ytile++ //move our Y coord +1
xtile = 0 //move our X coord back the start
else
//look ma, no hands!
end
``````

All total it saved me about 60 lines of code, so that's pretty neat!