9 lines
258 B
TypeScript
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);
|