A Platform to LEARN | CODE | ACHIEVE
ENTER THE NUMBER : 153
IT IS AN ARMSTRONG NUMBER
What we did - Our Approach
In this problem we have to check whether a given number is an armstrong number or not.An Armstrong number is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3*3*3 + 7*7*7 + 1*1*1 = 371.
To do so we declare a variable 'sum',which will store the result value(don't forget to initialize it with zero).Then,we update our 'sum' value by adding cube of remainder value(rem*rem*rem) to it in each iteration(until 'n' becomes 0).
After the last iteration,we compare the value of given number and our sum ,if both values are equal then given number is armstrong else it isn't.
For any Queries,suggestions,feel free to Mail us at :
For reporting any kind of copyright voilation,mail us at : firstname.lastname@example.org
© copyright CODE OF GEEKS