Hi, is there any way to check if an integer is even or odd?
*This post is locked for comments
Hi Youssef, thank you.
If ( #yournumber MOD 2) = 0 then
Message('even')
Else
Message('odd');
[int] mod 2 ==1 ??
Use the MOD operator.
X MOD 2 will result in 0 or 1, when X is respectively even or odd.
Funny is that the MOD operator is not (well) documented. But read some about it here www.mibuso.com/.../viewtopic.php
If ( [tag:yournumber] MOD 2) = 0 then
Message('even')
Else
Message('odd');
Hi, use the MOD 2 function to check if there's a remainder then it's odd if not it's even
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,232 Super User 2024 Season 2
Martin Dráb 230,064 Most Valuable Professional
nmaenpaa 101,156