Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. function smallestCommons(arr) {
  2. arr.sort((a,b)=>a>b?1:-1)
  3. let [div, num] = arr
  4.  
  5. while(div < arr[1]){
  6. if(num % div===0) {
  7. div++;
  8. } else {
  9. num += arr[1];
  10. div = arr[0]
  11. }
  12. }
  13. return num;
  14. }
  15.  
  16. console.log(smallestCommons([1,13]));
  17. //console.log(smallestCommons([23,18]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement