Advertisement
dabidabidesh

Untitled

May 31st, 2020
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //08. Special Numbers
  2. function specialNumbers(numb) {
  3.   for (let i = 1; i <= numb; i++)
  4.     if (isSpecial(i))
  5.       console.log(`${i} -> True`)
  6.     else
  7.       console.log(`${i} -> False`)
  8.  
  9.   function isSpecial(n) {
  10.     let str = n.toString()
  11.     let sum = 0
  12.     for (let i = 0; i < str.length; i++)
  13.       sum += +str[i]
  14.     if (sum === 5 || sum === 7 || sum === 11)
  15.       return true
  16.     else
  17.       return false
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement