Witte a program in java to print Armstrong numbers from 1 to 1000. Armstrong numbers are sum to each digit cube equal to number
Answers
Answered by
1
Answer:
class ArmstrongExample{
public static void main(String[] args) {
int c=0,a,temp;
int n=153;//It is the number to check armstrong.
temp=n;
while(n>0)
{
a=n%10;
Answered by
0
Answer:
public class ArmstrongNumbers {
public static void main(String[] args) {
try{
int[] num = new int[10];
int digit , k;
for (int i=0 ; i<=1000 ; i++){
int sum = 0;
k = i;
while (k>0) {
digit = k%10;
sum += Math.pow(digit,3);
k /= 10;
}
if (i == sum) {
System.out.print(i+" ");
}
}
}
catch (Exception e) {
System.out.println("Some error occured");
}
}
}
Please mark it as Brainliest.
Similar questions
Math,
3 months ago
Computer Science,
3 months ago
Science,
3 months ago
Social Sciences,
6 months ago
English,
6 months ago
Science,
10 months ago
Science,
10 months ago