Series of numbers that are divided by 3 This is a logical problem and I can't solve it. The problem goes like this:



There is a series of numbers:
$$3, 2, 1, 5$$

There is four ways to add the consecutive terms to have a number that is divided by 3 without leaving remainder (3 1 5 is not consecutive so it doesn't count):


3, that sums up 3.
3 2 1, that sums up 6.
2 1, that sums up 3.
1 5, that sums up 6.


There is another series that is:
$$6, 1, 4, 124, 3, 6, 512, 3, 1, 33, 2, 2, 32, 100, 813, 4, 41, 1, 3, 8, 213, 5, 7, 61, 8, 42, 1, 4, 2, 20, 8$$


  How many ways are there to sum up consecutive numbers that are divided by three?


It's there some trick? Fastest way to solve it?
You can look at the partial sums reduced modulo 3.

Suppose the original sequence is $a_1\ldots a_n$, then define a new sequence $b_0\ldots b_n$ by $b_k = \sum_{i=0}^k a_i\pmod{3}$. So basically you make the sequence of $b$'s by starting with a $0$ and then adding the next $a$ and reducing modulo $3$. Now if $b_k=b_l$ for some $i\neq j$ then $ 0 = b_k-b_l=\sum_{i=k}^l a_i \pmod{3}$ and we have found a sequential sum that is divisible by three.

So in your first example $(a_i)_i = (3, 2, 1, 5)$ then $(b_i)_i = (0, 0, 2, 0, 2)$. Now we are looking for places in the $b$ sequence where both numbers are the same:


$b_0=b_1$ which corresponds to the sequence $3$.
$b_0=b_3$ which corresponds to $3,2,1$.
$b_1=b_3$ which corresponds to $2,1$.
$b_2=b_4$ which corresponts to $1,5$.


To find the total number of consecutive sequences that have a sum divisible by three it is enough to count all pairs of indicies $i,j$ such that $b_i = b_j$.
But this is simple with combinatorics. If $x$ is the number of zeros in the sequence $y$ the number of ones and $z$ the number of twos. Then the total number is ${x \choose 2} + {y\choose 2} + {z\choose 2}$.

Indeed in the example $x=3$, $y=0$ and $z=2$ and ${3\choose 2} + {0\choose 2} +{2\choose 2} = 3+0+1=4$
how isn't there an application that you can just enter a number and get a list of every divisible number up to a specified range, Like say you wanted to get every number divisible by 12 up to 40,000

anyone get what I'm saying?

like sure you can just enter the number on a calculator and add it to itself then keep hitting the equals key but that's a lot of tedious work