Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApp13
- {
- public static class PowerUtil
- {
- public static int Exp(int x, int no)
- {
- if (no == 1)
- {
- return x;
- }
- var reminder = no % 2;
- var value = Exp(x, no / 2);
- return reminder == 0 ?
- (value * value) :
- (x * value * value);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement