answersLogoWhite

0

First, review the definition of an Armstrong, or narcissistic, number:

"...is a number that is the sum of its own digits each raised to the power of the number of digits."

So, you need to count the digits (to know what power to use), and extract the individual digits. This can be done in several ways; for example, you might convert the number to a string. In Java:

String numberAsString = "" + number;

Now it should be easy to figure out the length of the String (use the .length() method), and to extract the individual digits - check the methods available for strings. Then you need to convert the digits back to numeric data.

Another way is to get one digit at a time, starting from the right, using the "%" operator.

For example, 153 % 10 is equal to 3. Divide the number, 153, by 10 (integer division), then repeat to get the remaining digits. You might store the digits to an array.

First, review the definition of an Armstrong, or narcissistic, number:

"...is a number that is the sum of its own digits each raised to the power of the number of digits."

So, you need to count the digits (to know what power to use), and extract the individual digits. This can be done in several ways; for example, you might convert the number to a string. In Java:

String numberAsString = "" + number;

Now it should be easy to figure out the length of the String (use the .length() method), and to extract the individual digits - check the methods available for strings. Then you need to convert the digits back to numeric data.

Another way is to get one digit at a time, starting from the right, using the "%" operator.

For example, 153 % 10 is equal to 3. Divide the number, 153, by 10 (integer division), then repeat to get the remaining digits. You might store the digits to an array.

First, review the definition of an Armstrong, or narcissistic, number:

"...is a number that is the sum of its own digits each raised to the power of the number of digits."

So, you need to count the digits (to know what power to use), and extract the individual digits. This can be done in several ways; for example, you might convert the number to a string. In Java:

String numberAsString = "" + number;

Now it should be easy to figure out the length of the String (use the .length() method), and to extract the individual digits - check the methods available for strings. Then you need to convert the digits back to numeric data.

Another way is to get one digit at a time, starting from the right, using the "%" operator.

For example, 153 % 10 is equal to 3. Divide the number, 153, by 10 (integer division), then repeat to get the remaining digits. You might store the digits to an array.

First, review the definition of an Armstrong, or narcissistic, number:

"...is a number that is the sum of its own digits each raised to the power of the number of digits."

So, you need to count the digits (to know what power to use), and extract the individual digits. This can be done in several ways; for example, you might convert the number to a string. In Java:

String numberAsString = "" + number;

Now it should be easy to figure out the length of the String (use the .length() method), and to extract the individual digits - check the methods available for strings. Then you need to convert the digits back to numeric data.

Another way is to get one digit at a time, starting from the right, using the "%" operator.

For example, 153 % 10 is equal to 3. Divide the number, 153, by 10 (integer division), then repeat to get the remaining digits. You might store the digits to an array.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

To check whether the given number is an Avogadro number or not?

45


To find Armstrong number in java?

/*Program to find whether given no. is Armstrong or not. Example : Input - 153 Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no. */ class Armstrong{ public static void main(String args[]){ int num = Integer.parseInt(args[0]); int n = num; //use to check at last time int check=0,remainder; while(num > 0){ remainder = num % 10; check = check + (int)Math.pow(remainder,3); num = num / 10; } if(check == n) System.out.println(n+" is an Armstrong Number"); else System.out.println(n+" is not a Armstrong Number"); } }


Program to check whether the given number is an Armstrong number?

<html> <head> <Script Language="JavaScript"> var a,n,b=0,t; n=parseInt(window.prompt("enter n","0")); t=n; while(n>0) { a=n%10; b=b+a*a*a; n=n/10; } if(b==t) { document.writeln("Armstrong no"); } else { document.writeln("Not an Armstrong no"); } </script> </head> </html>


Write an algorithm to check whether the given number is odd or even?

Type your answer here... i think we should first enter 1 number then check it


Draw a flow chart to check whether a given number is prime or not?

[object Object]


Could you write a assembly language program in tasm To check whether a given number present in a sequence of given memory location containing the string to be checked in 8086?

8086 assembly language program to check wether given number is perfect or not


Write a shell programs for to check whether the given number is an Avogadro number or not?

Avogadro's number is a constant. Therefore only one number is equal to Avogadro's number.


Lab manual in mca 1st sem from ignou?

write a program in C to check whether a given number is apalindrome or not


To check whether the given number is even or odd?

Is the last digit 2, 4, 6, 8 or 0? If yes, it's even, else odd.


How can you tell whether a given number is a multiple of 2?

If it is even


How do you draw a Flowchart to find whether the given number is odd or even using counter?

first we write start and then read number and after that check the number is totaly divide by 2 or not if number is totally divide by 2 then number is even else number is odd.


To check whether given number is a prime number or not?

See whether the number is divisible by 2, and by all odd numbers up to the square root of the number. For numbers up to 100, it is enough to check the factors 2, 3, 5, and 7. For higher numbers you need to check more factors. For very large numbers (for example, hundreds of digits), more efficient methods are known, but those methods are also more complicated.

Trending Questions
How much is a model 390 16 ga moss-berg shotgun worth bolt action? Please a tip for better website for hostingI really need help? Quel est le nom de l'inventeur du BMX? I wear a nose ring. I switched it to a straight clear stud retainer for work and after a few hours my nose ring wouldn't fit back in. What type of piercing retainer works for a nose ring? What is 04 28 85 in roman numerals? Is -18 equivalent to the square root of -324? If the following data were linearized using logarithms what would be the equation of the regression line Round the slope and y-intercept of the regression line to three decimal places. x y 1 13 2 19 3? Who is Whitney to Eminem? What factors are thought to contribute to physiological fatigue during short-duration high intensity exercise? Why do babies always want their mom? How do you stop hellium escapin from a balloon what causes hellium to escape from a balloon? Can you iron cross stitch? Who wrote this qoute video games don't affect kids if pac-man affected us as kids we'd all be walking around in dark rooms eating magic pills while listening to repetitive electronic music? Naruto shippuden collection 20 release date? Where is Copenhegan found? When was a 1935 D series 1 dollar silver certificate printed? What is considered a full outer ring of an atom? How did the US encourage settlers to travel to Oregon and California after the Louisiana territory? What medications are harmful to the fetus? When did Central Park in New York City open In the late 1800's?