#include <stdio.h> #include <limits.h> int decomp(unsigned long int Val, unsigned char Res[12]) { int nb; for(nb=0;nb<12;nb++) { Res[nb] = Val % 10; if(Val < 10) break; Val /= 10; } return nb+1; } main() { unsigned long Candidat, SomCub; unsigned char T[12]; int res,nb; for(Candidat=0; Candidat<ULONG_MAX; Candidat++){ res = decomp(Candidat, T); for(nb=0,SomCub=0;nb<res;nb++){ SomCub += T[nb] * T[nb] * T[nb]; } if(Candidat == SomCub) printf("%ld est un nombre d'Armstrong\n", Candidat); if(Candidat%1000 == 0) printf("%ld \n", Candidat); } }