Advertisement
roronoa

highest composite number 85%

Oct 3rd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. const N = parseInt(readline());
  3.  
  4. let nbDivisors = (e) => {
  5.     let r = 0
  6.     for(let i = 1; i <= e; i++)
  7.         if(e%i == 0)
  8.             r++
  9.     return r
  10. }
  11. let isHCM = (f) => {
  12.     let max = nbDivisors(f)
  13.     for(let i = 1; i < f; i++)
  14.         if(nbDivisors(i) > max)
  15.             return false
  16.     return true
  17. }
  18. for(let i = N; i >= 1; i--)
  19. {
  20.     if(isHCM(i))
  21.     {
  22.         print(i,nbDivisors(i))
  23.         return  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement