Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //08. Special Numbers
- function specialNumbers(numb) {
- for (let i = 1; i <= numb; i++)
- if (isSpecial(i))
- console.log(`${i} -> True`)
- else
- console.log(`${i} -> False`)
- function isSpecial(n) {
- let str = n.toString()
- let sum = 0
- for (let i = 0; i < str.length; i++)
- sum += +str[i]
- if (sum === 5 || sum === 7 || sum === 11)
- return true
- else
- return false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement