Armstrong
If the sum of cube of each number is again equal to the number then it is a Armstrong number.
simple logic.
Refer sample Inputs and Outputs.
Input 1 : 153
Output: Armstrong Number
Reason((1 ‘ 1 ‘ 1 + 5’5"5 3“3"3=153) which is equal to the number)
Input 2: 134
Output: not a Armstrong
Reason((1 ‘1‘1 + 5‘5’5 2“2"2=134) which is not equal to the number )
#include <iostream> using namespace std; int main() { int origNum,num,rem,sum = 0,digit; cout<<"Enter an Integer : "; cin>>origNum; num = origNum; while (num != 0) { digit = num % 10; sum += digit * digit * digit; num /= 10; } if(sum == origNum) cout << "Armstrong Number\n"; else cout<<"Not a Armstrong Number \n"; return 0; }
Input_1:
Enter an Integer : 153
Output:
Armstrong Number
Input_2:
Enter an Integer : 407
Output:
Armstrong Number
Input_3:
Enter an Integer : 405
Output:
Not a Armstrong Number
Input_4:
Enter an Integer : 370
Output:
Armstrong Number
Input_5:
Enter an Integer : 371
Output:
Armstrong Number
Input_6:
Enter an Integer : 375
Output:
Not a Armstrong Number
Illustration of the Output:
More Q
- Determine if a person could attend all meetings in given interval times.
- Find the volume of a volley ball
- Find the maximum score obtained at the end of colour chess grid game.
- Find the number of pairs if positive integers with condition is even.
- Return the largest subset such that every pair meets the given condition.
- Find the number of index triplets that satisfy given condition.
- Handling multiple queries using array – sum, update, range.
- Find all the sequences that occur more than once in DNA molecule.
- Find the biggest number.
- Sum of cube of each number is again equal to the number then it is an Armstrong number.
- Hello World.
- Calculate the Cube Root.
- Find the count of consecutive 1’s present in array.
- Return an array with athletes relative ranks according to the score.
- Return a string of its base 7 representation.
- Return kth largest element in sorted order.
- Find all repeated elements in the array.
- Find atleast one duplicate number in the array.
- Find the maximum result of = a XOR b.