Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- power = (number, pow) => {
- let arr = [];
- let length = Math.ceil(pow * Math.log(2) / Math.log(10));
- arr[length-1] = 1;
- for(let i = 0; i < pow; i++)
- {
- for(let j = 0; j < length; j++)
- {
- if(arr[j] != null)
- {
- arr[j] *= number;
- if(arr[j] > 9)
- {
- temp = arr[j];
- arr[j] = temp % 10;
- if(arr[j-1] == null) arr[j-1] = 0;
- arr[j-1] += Math.floor(temp / 10);
- }
- }
- }
- }
- let answer = "";
- for(let i = 0; i < arr.length; i++)
- if(arr[i] != null) answer += arr[i];
- console.log(answer);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement