News for hackers. Stuff that matters.
Re:Divisible by 7 (2016) by petschge on Thursday May 20, 2021 @03:39PM (#27226071)
Wait: Can you always test for divisibility by $n$ in base $n+1$ like that?
Re:Divisible by 7 (2016) by J-Kuhn on Thursday May 20, 2021 @03:44PM (#27226133)
Yes.

A number in base $n$ is just $a*n^2+b*n^1+c$.

Because $n mod n-1 = 1$, you can replace every $n$ with $1$.

So $a*n^2+b*n^1+c mod n-1$ becomes $a+b+c mod n-1$

Re:Divisible by 7 (2016) by klyrs on Thursday May 20, 2021 @05:44PM (#27227752)
The trick for 11 generalizes for testing for divisibility by n+1 in base n, too
Re:Divisible by 7 (2016) by ouid on Thursday May 20, 2021 @07:32PM (#27228768)
yes, n^k-1 is always divisible by n-1.