diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-10-13 23:39:10 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-10-13 23:39:10 +0200 |
commit | 1dffae442cb35ab9daab39d33dbd5724d748aac3 (patch) | |
tree | 727f5d5be77594da8bd1ea49be8d8e88c65d2100 /numalgo.cpp | |
parent | 0f0fa69c8d5fec8c7507e27ba8f618018db1ee78 (diff) |
divmod: recursive -> iterative
Diffstat (limited to 'numalgo.cpp')
-rw-r--r-- | numalgo.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/numalgo.cpp b/numalgo.cpp index ee77afc..a8f2321 100644 --- a/numalgo.cpp +++ b/numalgo.cpp @@ -40,6 +40,7 @@ Bigint expmod(const Bigint &b,const Bigint &e,const Bigint &m){ assert(e>=0); assert(m>=1); if(m==1)return Bigint::zero; + if(e==0)return b; Bigint res(1); vector<bool> bits(e.bits()); for(int i=bits.size()-1;i>=0;i--){ |