Files
2023-07-25 22:00:12 +02:00

9 lines
258 B
TypeScript

export const isArmstrongNumber = (candidate: bigint | number): boolean =>
candidate
.toString()
.split('')
.map(BigInt)
.reduce((result, value, _index, arr) =>
result + (value ** BigInt(arr.length)), 0n
) === BigInt(candidate);