code.ashish.me

Atom feed

Recently added: 02 Count Of Subset Sum, 416 Partition Equal Subset Sum, 01 Subset Sum, 518 Coin Change 2, 983 Minimum Cost For Tickets

02 Check Armstrong Number

function checkArmstrong(num) {
  const digits = num.toString().split('')
  let sum = 0
  digits.forEach(value => {
    sum += value ** digits.length
  })
  return sum === num
}

console.log(checkArmstrong(153))

Created 2019-11-24T04:41:20+05:18 · Edit