Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- // raise to power
- List<KeyValuePair<Int32, Int64>> list = new List<KeyValuePair<Int32, Int64>>();
- Int64 number = 7;
- Int32 exp = 22;
- Int32 startExp = 1;
- while(true)
- {
- list.Add(new KeyValuePair<Int32, Int64>(startExp, number));
- number *= number;
- startExp *= 2;
- if(startExp > exp)
- {
- Int32 diff = exp - list[list.Count - 1].Key;
- while(diff != 0)
- {
- for(Int32 i = list.Count - 1; i >= 0; --i)
- {
- if(list[i].Key <= diff)
- {
- number *= list[i].Value;
- diff -= list[i].Key;
- }
- }
- }
- break;
- }
- }
- Console.WriteLine(number);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement