トピック
Erry estherrose123

Divisibility

How do I calculate if a number is divisible by a certain number?
1そうだね
プレイ済み
返信[1]
親投稿
Oscar PwnageBlock
It's very simple! You probably already know that a number is divisible by another if the remainder of their division is 0. The MOD operator returns this remainder, so you can do something as simple as... NUM1 MOD NUM2 == 0 ...to check if NUM1 is divisible by NUM2.
1そうだね
プレイ済み
返信[2]
親投稿
Oscar PwnageBlock
Please be aware that the MOD operator only works with whole numbers (integers) and possibly only positive numbers. If you try using decimal values, they will be rounded off first. If you really need it to work with decimals, you can probably develop a custom algorithm pretty easily.
0そうだね
プレイ済み
返信[3]
親投稿
Erry estherrose123
Oh ok! Thanks for your help! I'm new to all of this and you're always helping me out!
0そうだね
プレイ済み