fork download
  1. #include<iostream>
  2. #include<math.h>
  3. using namespace std;
  4. int main(){
  5. int n, tmp, taille=0, res=0;
  6. cout<<"please give a value for n"<<endl;
  7. cin>>n;
  8. tmp=n;
  9. while(tmp!=0){
  10. taille++;
  11. tmp/=10;
  12. }
  13. tmp=n;
  14. while(tmp){
  15. res+=pow(tmp%10,taille);
  16. tmp/=10;
  17. }
  18. if(n==res)
  19. cout<<n <<" is a digital invariant number"<<endl;
  20. else
  21. cout<<n <<" is not a digital invariant number"<<endl;
  22. return 0;
  23.  
  24. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
please give a value for n
22019 is not a digital invariant number