R
R
raster2021-01-12 15:11:05
Algorithms
raster, 2021-01-12 15:11:05

Calculate the value of an expression with large numbers, how?

An integer N is given. Calculate the following expression: (1^N + 2^N + 3^N + 4^N) mod 5,
where 0 <= N <= 10^100000
The program should not run for more than 0.2 seconds.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-01-12
@Rastr_0

(1 N + 2 N + 3 N + 4 N ) mod 5 = (1 + 2 N mod 4 + 3 N mod 4 + 4 N mod 4 ) mod 5

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question