initial implementation for exchange number problem