Fast modulo 3 or division algorithm?
Posted
by aaa
on Stack Overflow
See other posts from Stack Overflow
or by aaa
Published on 2009-11-08T17:59:17Z
Indexed on
2010/05/09
10:08 UTC
Read the original article
Hit count: 434
Hello
is there a fast algorithm, similar to power of 2, which can be used with 3, i.e. n%3. Perhaps something that uses the fact that if sum of digits is divisible by three, then the number is also divisible.
This leads to a next question. What is the fast way to add digits in a number? I.e. 37 -> 3 +7 -> 10 I am looking for something that does not have conditionals as those tend to inhibit vectorization
thanks
© Stack Overflow or respective owner