Finding total number of reversible numbers till billion (Python implementation), works fine until 10^6