Skip to content

Latest commit

 

History

History
64 lines (61 loc) · 3.03 KB

README.md

File metadata and controls

64 lines (61 loc) · 3.03 KB

ModPower

ModPower function can Calculate Big Expressions like (a^b) mod c in C# (System.Numerics -> BigInteger) and other programing languages.
and this is how is works:

Example

for example, you need to calculate a big Expression like this one:

(10000^100000) mod 45

it's impossible to calculate something like that using ordinary simple calculations!

this is the example of the way you can solve big Expression like (a^b) mod c = 10000^100000 mod 45 :

10000^100000 mod 45
= (10000^65536) x (10000^32768) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mod 45
= (10000 mod 45)^65536 x (10000^32768) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (10^65536) x (10000^32768) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (100^32768) x (10000^32768) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (1000000^32768) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (1000000 mod 45)^32768 x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (10^32768) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (100^16384) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (10000^8192) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (10000 mod 45)^8192 x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (10^8192) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (100^4096) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (10000^2048) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (10000 mod 45)^2048 x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (10^2048) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (100^1024) x (10000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (1000000^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (1000000 mod 45)^1024 x (10000^512) x (10000^128) x (10000^32) mood 45
= (10^1024) x (10000^512) x (10000^128) x (10000^32) mood 45
= (100^512) x (10000^512) x (10000^128) x (10000^32) mood 45
= (1000000^512) x (10000^128) x (10000^32) mood 45
= (1000000 mod 45)^512 x (10000^128) x (10000^32) mood 45
= (10^512) x (10000^128) x (10000^32) mood 45
= (100^256) x (10000^128) x (10000^32) mood 45
= (10000^128) x (10000^128) x (10000^32) mood 45
= (10000 mod 45)^128 x (10000^128) x (10000^32) mood 45
= (10^128) x (10000^128) x (10000^32) mood 45
= (100000^128) x (10000^32) mood 45
= (100000 mod 45)^128 x (10000^32) mood 45
= (10^128) x (10000^32) mood 45
= (100^64) x (10000^32) mood 45
= (10000^32) x (10000^32) mood 45
= (10000 mod 45)^32 x (10000^32) mood 45
= (10^32) x (10000^32) mood 45
= (100000^32) mood 45
= (100000 mod 45)^32 mood 45
= (10^32) mood 45
= (100^16) mood 45
= (10000^8) mood 45
= (10000 mod 45)^8 mood 45
= (10^8) mood 45
= (100^4) mood 45
= (10000^2) mood 45
= (10000 mod 45)^2 mood 45
= (10^2) mood 45
= (100^1) mood 45
= (10^1) mood 45 = 10

seems too much calculation; but not for a cpmputer, and it can be simply implemented!