I'm having trouble coming up with a solution to this problem.
Say you have two byte arrays with numbers stored in them backwards.
For example, say you have the numbers num1 = 843234 and num2 = 5430222124 stored in two byte arrays as follows
byte[] num1 = {4, 3, 2, 3, 4, 8};
byte[] num2 = {4, 2, 1, 2, 2, 2, 0, 3, 4, 5};
// The numbers this code will be used for are much
// larger; possibly hundreds of digits long.
I need to write three methods:
1. add - This function adds the two numbers together and stores the result in a new byte array (I can write this one easily.)
2. multiply - This function multiplies the two numbers together and stores the result in a new byte array (I'm having trouble getting this one started. This method can not call add, i.e. To take 765 * 6, I can't just add 765 to itself 6 times)
3. power - This function raises num1 to the power of num2 and stores it in a new byte array. (Once I figure out the multiply, I am allowed to call multiply, but I know there has to be a faster way to do it.)
Any help would be greatly appreciated. I just need help getting started on multiply and power, if you have any ideas.