An effective way to eat and fashion in ruby
2 answers
This is called modular exponentiation and is used in cryptography. Its quite easy to write a modular exponentiation algorithm, a demo is in the wikipedia article linked above.
You can use the openssl standard library to achieve your goal:
require 'openssl'
1_299_709.to_bn.mod_exp(1_300_751, 104_729) # => 90827
+10
source to share