Computer Science, asked by asjadkaifee007, 6 months ago

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 aasthaaastha160
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 udayagrawal49
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