tsekotsolov

Special numbers

Oct 7th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function special (number) {
  2.   for (let i = 1; i <= number; i++) {
  3.     let sum = [...i.toString()].map(Number).reduce((a, b) => a + b)
  4.  
  5.     if (sum === 5 || sum === 7 || sum === 11) {
  6.       console.log(`${i} -> True`)
  7.     } else {
  8.       console.log(`${i} -> False`)
  9.     }
  10.   }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment