Suppose we get an infinite stream of integers. $ x_1, x_2, … $,

a) Show that we can calculate whether the sum of all integers seen so far is divisible by a fixed integer $ N $ With $ O (log N) $ Bits of memory.

b) Leave $ N $ an arbitrary number, and let's assume we are given $ N $Hauptfaktorisierung: $ N = p_1 ^ {k_1} p_2 ^ {k_2} … p_r ^ {k_r} $, How would you check if $ N $ divides the product of all integers $ x_i $ So far, use as little memory as possible? Make note of the number of bits used in $ k_1, …, k_r $,

For part a) we know this for every prime number $ p ne 2, 5 $There is an integer

$ r $ so that to see if $ p $ divides a decimal number $ n $we interrupt $ n $ in $ r $-Tuple of decimal places, add these $ r $tuple and check if the sum is divisible by $ p $, But $ N $ is a fixed integer and not necessarily a prime. Is there a way to join the above sentence with any number?

For part b) for the product of $ x_i $ (call $ y $) is divisible by $ N $, then $ y $ must be divisible by everyone $ p_i ^ {k_i} $ (call $ a_i $, Since we get the prime factorization, we can only check if $ y $ is divisible by $ N $ by sharing $ y $ of each $ a_i $ and stop, if it fails, right? Would this lead to the use $ k_1 * … * k_r $ Bits?

Am I at least on the right track or am I completely wrong? Any help that understands this problem would be enormously helpful. Many Thanks.