#include <iostream>
#include <cstdint>
#include <limits>

int main()
{
    constexpr std::size_t NPEGS = 3U ;
    const char peg[NPEGS] = { 'A', 'B', 'C' } ;
    constexpr std::size_t MAX = std::numeric_limits<std::uintmax_t>::digits ;

    std::size_t ndisks ;
    std::cout << "ndisks ( 1 - " << MAX << ")? " ;
    std::cin >> ndisks ;

   if( ndisks > 0 && ndisks < MAX )
   {
      const std::uintmax_t num_moves = ( 1U << ndisks ) - 1 ; // 2^n - 1
      std::cout << ndisks << " disks, " << num_moves << " moves\n" ;

      // see: http://e...content-available-to-author-only...a.org/wiki/Tower_of_Hanoi#Binary_solution
      for( std::uintmax_t nmove = 1 ; nmove <= num_moves ; ++nmove )
      {
          const auto from = ( nmove & (nmove-1) ) % NPEGS ;
          const auto to = ( ( nmove | (nmove-1) ) + 1 ) % NPEGS ;
          std::cout << nmove << ". from " << peg[from] << " to " << peg[to] << '\n' ;
      }
   }
}
