Advertisement
Guest User

Untitled

a guest
May 20th, 2019
516
0
Never
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.     '555',
  13.    
  14.    
  15.    
  16.   ];
  17.  
  18.   const gets = this.gets || getGets(test);
  19.   const print = this.print || console.log;
  20.  
  21.  var n = Number(gets());
  22.  var arr = new Array;
  23.  
  24.  while(n>=2) {
  25.      if(n%11==0) {
  26.          n=n/11;
  27.          arr.push(11);
  28.      } else if(n%5==0) {
  29.          n=n/5;
  30.          arr.push(5);
  31.          //print(n);
  32.      } else if(n%3==0) {
  33.         n=n/3;
  34.         arr.push(3);
  35.        //print(n%3)
  36.      } else if(n%2==0) {
  37.        n=n/2;
  38.        arr.push(2);
  39.        //  print(n)
  40.      } else {
  41.          n-=1;
  42.         // print(n)
  43.      }
  44.  }
  45.  arr.reverse(function(a, b){return b - a});
  46.  //print(arr);
  47.  arr.forEach(element => {
  48.     print(element)
  49.  });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement