/**
* @function armstrongNumber
* @description Vérifie si un nombre fait partie des nombres d'Armstrong.
* @param {number} number - Le nombre à tester
* @returns {string}
* @example armstrongNumber(153) → 153 est un nombre d'Armstrong, car 13 + 53 + 33 = 153.
*/
function armstrongNumber(number) {
let numberString = number.toString();
let numberStringLength = numberString.length;
let result = 0;
let resultString = "";
for (let i = 0; i < numberStringLength; i++) {
result = result + parseInt(numberString[i])**numberStringLength;
resultString = resultString + " + " + numberString[i] + "" + numberStringLength + "";
}
const formattedNumber = formatNumberResult(number);
if (result === number) {
return `${formattedNumber} est un nombre d'Armstrong, car ${resultString.slice(2)} = ${formatNumberResult(result)}.`;
} else {
return `${formattedNumber} n'est pas un nombre d'Armstrong, car ${resultString.slice(2)} = ${formatNumberResult(result)}.`;
}
}
/* Exports */
export { armstrongNumber };