JavaScript Program to Display Armstrong Number Between Two Intervals Last Updated : 19 Feb, 2024 Comments Improve Suggest changes Like Article Like Report An Armstrong number is a number that is equal to the sum of its digits each raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153. In this article, we'll explore how to create a JavaScript program to display all Armstrong numbers within a given range. To find Armstrong numbers between two intervals, we need to: Iterate through all numbers in the given range.For each number, determine the number of digits (n).Calculate the sum of each digit raised to the power of n.Check if the calculated sum is equal to the original number. If it is, the number is an Armstrong number.Basic ApproachHere's a simple implementation to find and display Armstrong numbers between two given intervals: JavaScript function isArmstrongNumber(num) { let sum = 0; let temp = num; const numberOfDigits = num.toString().length; while (temp > 0) { let digit = temp % 10; sum += Math.pow(digit, numberOfDigits); temp = Math.floor(temp / 10); } return sum === num; } function displayArmstrongNumbers(start, end) { for (let i = start; i <= end; i++) { if (isArmstrongNumber(i)) { console.log(i); } } } displayArmstrongNumbers(100, 1000); Output153 370 371 407Using Array MethodsAlternatively, you can use JavaScript array methods to make the code more concise: JavaScript function isArmstrongNumber(num) { return num.toString() .split('') .map(Number) .reduce((sum, digit, _, {length}) => sum + Math.pow(digit, length), 0) === num; } function displayArmstrongNumbers(start, end) { for (let i = start; i <= end; i++) { if (isArmstrongNumber(i)) { console.log(i); } } } displayArmstrongNumbers(100, 1000); Output153 370 371 407The split() method is used to convert the number to an array of digits, map(Number) converts each digit back to a number, and reduce() calculates the sum of each digit raised to the power of the number of digits. Comment More infoAdvertise with us Next Article JavaScript Program to Display Armstrong Number Between Two Intervals V vkash8574 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads JavaScript Program to Display Armstrong Numbers Between 1 to 1000 Armstrong number is a number equal to the sum of its digits raised to the power 3 of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153. This article will explore how to find Armstrong numbers between 1 to 1000 using JavaScript. Approach 1: Display Armstrong 2 min read JavaScript Program for Armstrong Numbers In this article, we will see a JavaScript program to check whether the given number is an Armstrong number or not. An Armstrong Number is an n-digit number that is the sum of the nth power of its all digits. For instance, Consider a 3-digit number, i.e., 153, which is a 3-digit number, & the sum 4 min read How to Use Swing Applet in Java? In this article, we will be using the swing Applet or JApplet in Java. Here, we will make a simple multiplication application that will multiply the two input numbers. Approach to Using Swing Applet in JavaWe need to import the packages for Swing and AWT Components.Once the packages are imported, we 4 min read java.time.Period Class in Java The Period Class in Java class obtains a quantity or amount of time in terms of years, months and days. The time obtained is a date-based amount of time in the ISO-8601 calendar system, such as '4 years, 5 months, and 6 days. The units which are supported for a period are YEARS, MONTHS, and days. Al 5 min read C Program to Display Armstrong Number Between Two Intervals Write a C program to find and display all Armstrong numbers between two given intervals. An Armstrong number (also known as a narcissistic number or pluperfect number) of a given number of digits is a number that is equal to the sum of its own digits each raised to the power of the number of digits. 6 min read Like