solving an exponential triangle problem