Jump to content
Macro Express Forums

How to test if a number is a multiple of 5


margaret

Recommended Posts

1) Divide your number by 5, save this result (res1)

2) Multiply res1 by 5, save this result (res2)

3) If your number equals res2, your number is divisible by 5

 

Same with odd/even numbers, using 2 as the divisor.

This works if you are using Integer variables.

 

Something like this might work if you want to use Decimal variables:

Variable Modify Decimal: %D2% = %D1% / 5
Variable Modify Decimal: Copy fraction part of %D2% to %D3%
Variable Modify Decimal: %D4% = %D3% * 5
Round Decimal Variable %D4% to 0 decimal places
If Variable %D4% = 0
 // Divisible by 5
Else
 // Not divisible by 5
End If

Link to comment
Share on other sites

1) Divide your number by 5, save this result (res1)

2) Multiply res1 by 5, save this result (res2)

3) If your number equals res2, your number is divisible by 5

 

Same with odd/even numbers, using 2 as the divisor.

 

I'm afraid this doesn't make sense to me. Isn't dividing by 5 and then multiplying by 5 the same thing as multiplying by 1??

 

125 / 5 = 5.

5 x 5 = 125.

Link to comment
Share on other sites

I'm afraid this doesn't make sense to me. Isn't dividing by 5 and then multiplying by 5 the same thing as multiplying by 1??

 

125 / 5 = 5.

5 x 5 = 125.

Try these:

124/5 = 24

24*5 = 120

125 <> 120, therefore 124 is not a multiple of 5

 

125/5 = 25 (not 5 as you wrote above)

25*5 = 125

125 = 125, therefore 125 is a multiple of 5

 

QED

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...