Advertisement
madopew

Untitled

Sep 10th, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. power = (number, pow) => {
  2.     let arr = [];
  3.     let length = Math.ceil(pow * Math.log(2) / Math.log(10));
  4.     arr[length-1] = 1;
  5.     for(let i = 0; i < pow; i++)
  6.     {
  7.         for(let j = 0; j < length; j++)
  8.         {
  9.             if(arr[j] != null)
  10.             {
  11.                 arr[j] *= number;
  12.                 if(arr[j] > 9)
  13.                 {
  14.                     temp = arr[j];
  15.                     arr[j] = temp % 10;
  16.                     if(arr[j-1] == null) arr[j-1] = 0;
  17.                     arr[j-1] += Math.floor(temp / 10);
  18.                 }
  19.             }  
  20.         }
  21.     }
  22.     let answer = "";
  23.     for(let i = 0; i < arr.length; i++)    
  24.         if(arr[i] != null) answer += arr[i];    
  25.     console.log(answer);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement