Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main(){
- int n, tmp = 0, t, d;
- scanf("%d", &n);
- int i = 0;
- while(tmp < n){
- tmp = 0;
- t = n;
- while(t > 0){
- d = t%10;
- tmp += pow(d, i);
- t /= 10;
- }
- i++;
- }
- if(tmp == n){
- printf("%d is an armstrong number\n", n);
- } else{
- printf("%d is not an armstrong number\n", n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement