#include int checkIfArmstrong(long x); long nextArmstrongN(long N); void firstMArmstrong(int M); int main() { int k=5; printf("Printing first %d Armstrong numbers:\n",k); firstMArmstrong(k);printf("\n"); return 0; } int checkIfArmstrong(long x) { long sum = 0,i = 0,n=x; while(n>0) { sum =sum + (n%10)*(n%10)*(n%10); n = n/10; } if(sum == x) return 1; else return 0; } long nextArmstrongN(long N) { long i=0; for(i = N+1;i > N;i++) { //printf("%ld\n",i); if(checkIfArmstrong(i)) return i; } return 0; } void firstMArmstrong(int M) { long count = 0,n=0; while(count < M) { n = nextArmstrongN(n); printf("%ld\n",n); count++; } }