Armstrong numbers

This commit is contained in:
2023-07-25 22:00:12 +02:00
parent 7ee6d469b4
commit 1ccf7cb4fa
19 changed files with 45136 additions and 0 deletions

View File

@@ -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);