I am using the C++ language. I want to calculate these 2 expressions:-
In our case, $x= 100000000000000000$
Expression(1)
$$((3^x-1)/2)\mod7$$
The numerator $3^x-1$ is always divisible by $2$(basic number theory)
I calculated the above expression using Extended-Euclid-Gcd algorithm. The above algorithm only works when gcd(denominator,mod-value)=1...in our case $\gcd(2,7)=1$ . So we were able to calculate it using the above algorithm.
Expression(2)
$$((3^x-1)/2)\mod6$$
The numerator $3^x-1$ is always divisible by $2$(basic number theory-again)
Now, how do I calculate the above expression as $\gcd(2,6)=2$ which is not equal to $1$ ?