by Dinesh Thakur Category: Control Structures

Algorithm for Armstrong Number:

step 1:Set s=0

step 2: Read num

step 3: Set b=num

step 4: Repeat through step-7 while num greater than 0

step 5: r=num%10

step 6: s=s+(r*r*r)

step 7: num=num/10

step 8: If b equals to s then print “it is an Armstrong number”

Else print "it is not an Armstrong number"

step 9: Exit


Here is the Java Example for Armstrong Number:

import java.util.Scanner;

public class ArmstrongNumber
                 public static void main(String args[])
                    Scanner s1=new Scanner(;
                    int num,b,s=0,r;
                    System.out.println("Enter A Number");
                    num =s1.nextInt();
                    b= num;
                            r= num%10;
                            num = num/10;
                            if (b==s)
              System.out.println(b+" is an Armstrong Number");
              System.out.println(b+" not an Armstrong Number");

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles