Armstrong numbers
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
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);
|
||||
Reference in New Issue
Block a user