Which is the best way, in C, to see if a number is divisible by another?
问题 Which is the best way, in C, to see if a number is divisible by another? I use this: if (!(a % x)) { // this will be executed if a is divisible by x } Is there anyway which is faster? I know that doing, i.e, 130 % 13 will result into doing 130 / 13 per 10 times. So there are 10 cycles when just one is needed (I just want to know if 130 is divisible by 13). Thanks! 回答1: I know that doing, i.e, 130 % 13 will result into doing 130 / 13 per 10 times Balderdash. % does no such thing on any