TizzyT

Pow (Exponentiation) - TizzyT

Mar 31st, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.53 KB | None | 0 0
  1. 'Pretty slow but logically sound exponentiation function
  2.     Private Function Pow(ByVal num1 As BigInteger, ByVal num2 As ULong) As BigInteger
  3.         Dim R As BigInteger = num1
  4.         Dim its As ULong = 1
  5.         While its < num2
  6.             Dim Rcrnt As BigInteger = num1
  7.             Dim crnt As ULong = 1
  8.             While (crnt * 2) + its < num2
  9.                 Rcrnt *= Rcrnt
  10.                 crnt *= 2
  11.             End While
  12.             R *= Rcrnt
  13.             its += crnt
  14.         End While
  15.         Return R
  16.     End Function
Advertisement
Add Comment
Please, Sign In to add comment