#include <limits>
#include <iostream>
unsignedint pow2( unsignedint n )
{
if( n >= std::numeric_limits<unsignedint>::digits ) return 0 ;
unsignedint result = 1 ;
// return result << n ;
for( unsignedint i=0; i<n; ++i )
{
result *= 2 ;
}
return result;
}
int main()
{
for( unsignedint n = 0 ; n < 128; ++n )
{
unsignedint result = pow2(n) ;
if( result > 0 ) std::cout << "2^" << n << " == " << result << '\n' ;
else
{
std::cerr << "the number 2^" << n
<< " is too big to be represented by an unsigned int\n" ;
return 0 ;
}
}
}