Click here to Skip to main content
15,896,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
How to print Armstrong Numbers 1 To 99999999999
Posted

If you are going to post your homework, at least try to make it look like you have attempted to do something yourself!

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, or learn the Magic Words: "Do you want fries with that?"

I suggest you start with Google: http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=Print+Armstrong+Numbers[^]
 
Share this answer
 
Make a loop from 1 to 99999999999 and test if the number is an Armstrong's one. How? I won't tell you, it would be just spoiler.
 
Share this answer
 
solving armstrong number is really fun but you need the concept on how to solve it.
I suggest you use this one: http://illuminations.nctm.org/LessonDetail.aspx?id=L648

try solve it with ordinary looping then proceed with recursive. You can always post your solution here whenever you encountered roadblocks along the way :)
 
Share this answer
 
you can write a simple program like this, though it may not be the most optimized one (note that max_Limit can be 2,147,483,647 for int in c#, hence plan accordingly)

C#
namespace Armstrong_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            int sum = 0;
            int remainder_Number = 0;
            int length=0;
            int max_Limit = 9999;
            Console.WriteLine("The List of Armstrong Number's are :-");
            for (int number = 1; number <= max_Limit; number++)
            {
                length = sum = 0;
                for (int counter = number; counter > 0; counter = counter / 10)
                {
                    length++;
                }
                for (int counter = number; counter > 0; counter = counter / 10)
                {
                    remainder_Number = counter % 10;
                    sum = sum + (int)Math.Pow(remainder_Number, length);
                }
                if (sum == number)
                    Console.WriteLine(number);
            }
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900