Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Pretty slow but logically sound exponentiation function
- Private Function Pow(ByVal num1 As BigInteger, ByVal num2 As ULong) As BigInteger
- Dim R As BigInteger = num1
- Dim its As ULong = 1
- While its < num2
- Dim Rcrnt As BigInteger = num1
- Dim crnt As ULong = 1
- While (crnt * 2) + its < num2
- Rcrnt *= Rcrnt
- crnt *= 2
- End While
- R *= Rcrnt
- its += crnt
- End While
- Return R
- End Function
Advertisement
Add Comment
Please, Sign In to add comment