EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

✅ What is an Armstrong Number?

A number is an Armstrong number if:

 

sum of cubes of its digits = the number itself (for 3-digit numbers)

Example: 153 = 1³ + 5³ + 3³ = 153

 

✅ Java Code:

import java.util.Scanner;

 

public class ArmstrongNumber {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

 

// Input a number

System.out.print(“Enter a number: “);

int number = sc.nextInt();

int original = number;

int result = 0;

 

while (number != 0) {

int digit = number % 10;

result += digit * digit * digit; // cube of digit

number = number / 10;

}

 

if (result == original)

System.out.println(original + ” is an Armstrong number.”);

else

System.out.println(original + ” is not an Armstrong number.”);

}

}

📌 Sample Input/Output:

Input: 153

Output: 153 is an Armstrong number.

 

Java Armstrong’s number

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer