Computer Science, asked by rogerssteve, 1 year ago

how to find armstrong number

Answers

Answered by Krishgh
4
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to thenumber itself. For example, 371 is anArmstrong number since 3**3 + 7**3 + 1**3 = 371. Write a program to find allArmstrong number in the range of 0 and 999.
Answered by Brenquoler
0

An Armstrong number is a number whose sum of cubes of digits is equal to the number itself.

For example:

153 = 1³+5³+3³

1+125+27

=153

Program:

import java. util.*;

class Armstrong

{

public static void main (string args [])

{

Scanner sc = new Scanner

int n, r, p, s=0, m;

System.out.println ("Enter a number");

n=sc.nextInt();

while

{

r=n%10

p=r*r*r;

s=s+p;

n=n/10;

}

if (m==s)

System.out.println (m+"is Armstrong");

else

System.out.println (m+"is not Armstrong");

}

}

Similar questions