alias3glw

Numero perfecto

May 27th, 2015
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9.     double N,k,n=2,acum=0;
  10.    
  11.     cout<<"Ingrese un numero"<<endl;
  12.     cin>>N;
  13.    
  14.     do {
  15.         acum= pow(2,k-1)*(pow(2,k)-1);
  16.        
  17.         if ( acum<N ){
  18.            
  19.             acum=0;
  20.             k=k+1;
  21.         }
  22.         else if ( acum>N) {
  23.            
  24.             cout<<"No es perfecto"<<endl;
  25.            
  26.         }
  27.         else if ( acum == N ) {
  28.              cout<<"Es numero perfecto"<<endl;
  29.            
  30.         }
  31.        
  32.         }while ( acum < N );
  33.          
  34.     system("PAUSE");
  35.     return EXIT_SUCCESS;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment