Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
Created armstrong
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilshad-mohammad authored Oct 29, 2024
1 parent 5aefa58 commit 815ec36
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Beginner Level 📁/Armstrong numbers/armstrong
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//armstrong is a number if the sum of cube of each element gives the same number e.g cude of 1,5,3 gives 153.

#include<iostream>
#include<math.h>
using namespace std;

int main( )
{
int n;
cin>>n;
int original = n;
int sum = 0;

while(n>0){
int lastdigit = n%10;// returns Remainder
sum+= lastdigit*lastdigit*lastdigit;// calculation and Addition of cube from last digit...
n=n/10;
}
if(sum==original){
cout<<"armstrong"<<endl;
}
else{
cout<<"not-armstrong"<<endl;
}
return 0;
}

0 comments on commit 815ec36

Please sign in to comment.