SHARE
TWEET

Kaspichan Numbers BigInt()

stanislavtrifonov May 28th, 2019 90 in 313 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const getGets = (arr) => {
  2.     let index = 0;
  3.  
  4.     return () => {
  5.         const toReturn = arr[index];
  6.         index += 1;
  7.         return toReturn;
  8.     };
  9. };
  10. // this is the test
  11. const test = [
  12.     '1000'
  13. ];
  14.  
  15. const gets = this.gets || getGets(test);
  16. const print = this.print || console.log;
  17.  
  18. let N = BigInt(gets());
  19. let divider256 = BigInt('256')
  20.  
  21. let arrAlphabet = [
  22.     'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
  23.     'aA', 'aB', 'aC', 'aD', 'aE', 'aF', 'aG', 'aH', 'aI', 'aJ', 'aK', 'aL', 'aM', 'aN', 'aO', 'aP', 'aQ', 'aR', 'aS', 'aT', 'aU', 'aV', 'aW', 'aX', 'aY', 'aZ',
  24.     'bA', 'bB', 'bC', 'bD', 'bE', 'bF', 'bG', 'bH', 'bI', 'bJ', 'bK', 'bL', 'bM', 'bN', 'bO', 'bP', 'bQ', 'bR', 'bS', 'bT', 'bU', 'bV', 'bW', 'bX', 'bY', 'bZ',
  25.     'cA', 'cB', 'cC', 'cD', 'cE', 'cF', 'cG', 'cH', 'cI', 'cJ', 'cK', 'cL', 'cM', 'cN', 'cO', 'cP', 'cQ', 'cR', 'cS', 'cT', 'cU', 'cV', 'cW', 'cX', 'cY', 'cZ',
  26.     'dA', 'dB', 'dC', 'dD', 'dE', 'dF', 'dG', 'dH', 'dI', 'dJ', 'dK', 'dL', 'dM', 'dN', 'dO', 'dP', 'dQ', 'dR', 'dS', 'dT', 'dU', 'dV', 'dW', 'dX', 'dY', 'dZ',
  27.     'eA', 'eB', 'eC', 'eD', 'eE', 'eF', 'eG', 'eH', 'eI', 'eJ', 'eK', 'eL', 'eM', 'eN', 'eO', 'eP', 'eQ', 'eR', 'eS', 'eT', 'eU', 'eV', 'eW', 'eX', 'eY', 'eZ',
  28.     'fA', 'fB', 'fC', 'fD', 'fE', 'fF', 'fG', 'fH', 'fI', 'fJ', 'fK', 'fL', 'fM', 'fN', 'fO', 'fP', 'fQ', 'fR', 'fS', 'fT', 'fU', 'fV', 'fW', 'fX', 'fY', 'fZ',
  29.     'gA', 'gB', 'gC', 'gD', 'gE', 'gF', 'gG', 'gH', 'gI', 'gJ', 'gK', 'gL', 'gM', 'gN', 'gO', 'gP', 'gQ', 'gR', 'gS', 'gT', 'gU', 'gV', 'gW', 'gX', 'gY', 'gZ',
  30.     'hA', 'hB', 'hC', 'hD', 'hE', 'hF', 'hG', 'hH', 'hI', 'hJ', 'hK', 'hL', 'hM', 'hN', 'hO', 'hP', 'hQ', 'hR', 'hS', 'hT', 'hU', 'hV', 'hW', 'hX', 'hY', 'hZ',
  31.     'iA', 'iB', 'iC', 'iD', 'iE', 'iF', 'iG', 'iH', 'iI', 'iJ', 'iK', 'iL', 'iM', 'iN', 'iO', 'iP', 'iQ', 'iR', 'iS', 'iT', 'iU', 'iV'
  32. ];
  33.  
  34.  
  35. let arr256 = [];
  36. let temp256 = [];
  37. let remainder256 = 0;
  38. let tempNumber256 = 0;
  39. let arrFinal = [];
  40.  
  41. tempNumber256 = N;
  42.  
  43.  
  44. for ( i = 0 ;  ; i++ ) {
  45.  
  46.     remainder256 = tempNumber256 % divider256;
  47.     tempNumber256 = (tempNumber256 / divider256);
  48.  
  49.     //print(tempNumber256)
  50.  
  51.     if ( tempNumber256 < BigInt('1') ) {
  52.  
  53.         arrFinal.splice(0 , 0, arrAlphabet[remainder256.toString()]);
  54.        
  55.         break;
  56.  
  57.     } else {
  58.  
  59.         arrFinal.splice(0 , 0, arrAlphabet[remainder256.toString()]);
  60.         //print(remainder256.toString())
  61.  
  62.     }
  63.  
  64. }
  65.  
  66. print(arrFinal.join(''))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top