Advertisement
sci4me

long pow

Mar 7th, 2015
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. private static long pow(final long b, final long e)
  2.     {
  3.         long base = b;
  4.         long exp = e;
  5.         long result = 1;
  6.  
  7.         while (exp != 0)
  8.         {
  9.             if ((exp & 1) == 1)
  10.                 result *= base;
  11.             exp >>= 1;
  12.             base *= base;
  13.         }
  14.  
  15.         return result;
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement