# What is value of the equation ?

the equation is ( ( (x * x * (x+1) ) / 2 ) - 1) %m

x is <=10^18 ,m <=10^6…

I want to know , how I can use modular arithmetic to solve the following equation…

now it depends on your coding language whether you use python or c++
of you use python then there will not be any problem regarding to your question and in that case you can directly calculate mod after multiplying numbers
but in case of c++ since our limit is very small so that we will have to use some maths
like
split your mod at every operator and again take mod of full function

( ( (x * x * (x+1) ) / 2 ) - 1) %m = (( (x * x * (x+1) )%m) /2 - 1 %m ) %m = (((x % m)(x % m)((x+1) % m) % m) / 2 - 1 % m) % m

that’s it you will just have to split your mod at every operator and don’t forget to take mod of overall term too…
have a good day.

1 Like

From a live contest!! Remove this question!

you can’t ask a question from a live contest…google it…and u will surely get what is necessary and sufficient.