Skip to content

Instantly share code, notes, and snippets.

View YoosufAathil's full-sized avatar
🎯
Focusing

Yoosuf Aathil YoosufAathil

🎯
Focusing
View GitHub Profile
@YoosufAathil
YoosufAathil / armstrong_numbers_finder.js
Created April 11, 2024 17:58
This gist contains the JavaScript solution for the quiz component of the DuoThan 4.0 competition. The code efficiently identifies all Armstrong numbers within the range of 0 to 100,000 using a systematic algorithm. It utilizes functions to check if a number is an Armstrong number and to find all Armstrong numbers within the specified range.
// Function to check if a number is an Armstrong number
function isArmstrong(number) {
// Convert the number to a string to determine its length
let numStr = String(number);
let numDigits = numStr.length;
// Calculate the sum of the digits raised to the power of the number of digits
let sumOfDigits = numStr.split('').reduce((sum, digit) => sum + Math.pow(parseInt(digit), numDigits), 0);
// Check if the sum is equal to the original number